`

MySQL 查看约束,增添约束,删除约束

 
阅读更多
http://www.educity.cn/wenda/592607.html

http://blog.csdn.net/sadfishsc/article/details/7496979

MySQL 查看约束,添加约束,删除约束
  
查看表的字段信息:desc 表名;
查看表的所有信息:show create table 表名;
添加主键约束:alter table 表名 add constraint 主键 (形如:PK_表名) primary key 表名(主键字段);
添加外键约束:alter table 从表 add constraint 外键(形如:FK_从表_主表) foreign key 从表(外键字段) references 主表(主键字段);
删除主键约束:alter table 表名 drop primary key;
删除外键约束:alter table 表名 drop foreign key 外键(区分大小写);

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics