为了账号安全,请及时绑定邮箱和手机立即绑定
慕课网数字资源数据库体验端
与MySQL的零距离接触_学习笔记_慕课网
为了账号安全,请及时绑定邮箱和手机立即绑定

与MySQL的零距离接触

平然 学生
难度入门
时长 8小时29分
  • ESCAPE 过滤1后面的%为普通字符
    查看全部
    0 采集 收起 来源:MySQL 字符函数

    2017-06-02

  • 删除 主键约束 alter table tb2 drop primary key; 删除 唯一约束 alter table tb2 drop index username; 注意删除的是约束不是字段 删除外键约束 alter table tb2 drop foreign key 外键别名(constraint); 添加删除约束跟字段时 用add drop 需要修改列定义时 alter table tb2 modify id smallint unsigned first; 移动到最前面 修改时 大类型->小类型 可能造成数据丢失 修改列名称 alter table tb2 change pid p_id int not null; change 修改列名称和定义 修改数据表名字 rename table tb_name to tb_name1; alter table tb_name rename tb_name1;
    查看全部
  • 删除 主键约束 alter table tb2 drop primary key; 删除 唯一约束 alter table tb2 drop index username; 注意删除的是约束不是字段 删除外键约束 alter table tb2 drop foreign key 外键别名(constraint);
    查看全部
  • 修改数据表 添加 单列 alter table tb_name add 列名 列类型 [ first | after 列] 删除 列 alter table tb_name drop 列名; alter table tb_name drop 列名1 drop 列名2, add 列3 类型; 增加约束 删除约束 alter table tb_name add id smallint unsigned; 主键约束 alter table tb_name add constraint pk_id primary key (id); 唯一约束 alter table tb_name add unique (username); 外键约束 alter table tb_name add foreign key (pid) references provinces(id); 添加/删除默认约束 alter table tb_name alter age set default 15; alter table tb_name alter age drop default;
    查看全部
  • from某一个库,当前数据库不会发生改变
    查看全部
  • 加密函数 更改密码 set password=password('xinmima');
    查看全部
    0 采集 收起 来源:MySQL 加密函数

    2017-06-02

  • 修改数据表 添加 单列 alter table tb_name add 列名 列类型 [ first | after 列] 删除 列 alter table tb_name drop 列名; alter table tb_name drop 列名1 drop 列名2, add 列3 类型;
    查看全部
  • 信息函数
    查看全部
    0 采集 收起 来源:MySQL 信息函数

    2017-06-02

  • DELETE t1 FROM tdb_goods as t1 LEFT JOIN ..... 这儿的t1指的并不是原表,而是原表的副本t1,在与t2进行链接后得到的新的t1. 这个临时的t1表的数据即是要删除的多余的数据 多表删除.
    查看全部
    0 采集 收起 来源:多表删除

    2017-06-02

  • 外键约束参照 create table users ( id int unsigned primary key auto_increment, address int , foreign key address references province(id) on delete cascade ) on delete cascade 从父表删除或更新时 外键表自动更新。 set null 同上 restrict 拒绝对父表的删除或更新操作 no action
    查看全部
  • 日期时间函数
    查看全部
  • foreign key 存储默认引型 INNODB show create table tb5; create table users ( id int unsigned primary key auto_increment, address int , foreign key address references province(id) ) show index from tb4;
    查看全部
  • 数值运算符与函数
    查看全部
  • 插入用set,与value区别,这个可以用子查询
    查看全部
  • 主键可以看成是特殊的唯一约束 unique 一个数据表可以存在多个 unique 可以存在null 值 create table [if not exists] 表名 ( id int auto_increment primary key, name varchar(20) unique, age int unsigned ); 默认约束 default() 范围约束 check() create table [if not exists] 表名 ( id int auto_increment primary key, name varchar(20) unique, age int unsigned check(age>=1000 and age<=10000), sex enum('1','2') default ('1'));
    查看全部

举报

0/150
提交
取消
课程须知
要想学习本课程,你只需要知道数据库是个什么东东就足够了,是不是很easy?!
老师告诉你能学到什么?
1、MySQL安装与配置 2、数据类型 3、流程控制与运算符 4、DDL、DCL、DQL、DML 5、常用函数 6、表类型(存储引擎) 7、图形化工具
友情提示:

您好,此课程属于迁移课程,您已购买该课程,无需重复购买,感谢您对慕课网的支持!