mysql操作之二

 

特殊数据类型
表约束
表连接
索引
触发器
安全性
DB设计

 

 alter table student modify id int primary key;
主銉不可重复修改
 alter table student modify id int auto_increment;

 

特殊数据类型
Enum
Set
Text
Blob
TIMESTAMP 
默认值

create table users (
    id integer,
     name varchar(20),
     likes enum ('game','sleep','film')
);

show  create table users;
MySQL约束
MySQL约束

常见约束
检查约束(MySQL目前不支持)
非空约束not null
唯一约束unique
主键约束
外键约束

定义唯一约束unique     unique(列1,列2)
定义非空约束not null
定义主键约束
  primary key:不允许为空,不允许重复
  删除主键:alter table tablename drop primary key ;
定义主键自动增长
  auto_increment
主键一般的自动增长中在一起使用。
定义外键约束
constraint ordersid_FK foreign key(ordersid) references orders(id),
删除外键约束
alter table orders drop foreign key ordersid_FK;
增加外键约束

 

MySQL索引

索引作用
索引支持
索引分类
索引创建
索引设计
Orcale索引

 

MySQL连接:

table_reference [INNER | CROSS] JOIN table_factor [join_condition]
  | table_reference STRAIGHT_JOIN table_factor
  | table_reference STRAIGHT_JOIN table_factor ON condition
  | table_reference LEFT [OUTER] JOIN table_reference join_condition
  | table_reference NATURAL [LEFT [OUTER]] JOIN table_factor
  | table_reference RIGHT [OUTER] JOIN table_reference join_condition
  | table_reference NATURAL [RIGHT [OUTER]] JOIN table_factor 

 

连接分类
交叉连接
内连接
左外连接
右外连接
全连接
自连接

 

posted @ 2016-09-14 17:34  微风星宇  阅读(157)  评论(0编辑  收藏  举报