Mariadb数据库

添加非空约束

alter table 表1 modify 字段名 类型 ;

  

添加自动增长

alter table  表1 modify 字段 类型 auto_increment

 

主键约束

alter table 表1 add primary key(主键字段名)
alter table 表1 add constraint 主键名 primary key(主键字段名)

 

删除主键

alter table 表1 drop primary key

 

唯一约束

alter table 表1 add unique key(字段名)
alter table 表1 add unique key 约束名(字段名)

 

删除唯一约束

alter table 表1 drop index 约束名

 

外键

alter table 表1 add constraint 外键名 foreign key(字段名) references 表2(字段名)

 

posted on 2018-07-23 15:07  小骆骆  阅读(228)  评论(0编辑  收藏  举报

导航