当前位置:Gxlcms > 数据库问题 > mysql操作之二

mysql操作之二

时间:2021-07-01 10:21:17 帮助过:2人阅读

 

 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 

 

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

 

mysql操作之二

标签:

人气教程排行