首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

批改主键和外键

2012-09-28 
修改主键和外键?--删除主键并添加新主键 alter table 表名 drop column 主键名 alter table 表名add 主键

修改主键和外键

?

--删除主键并添加新主键 alter table 表名 drop column 主键名; alter table 表名     add 主键列名 int not null primary key auto_increment;--删除约束alter table 表名 drop constraint 约束名--添加主键约束alter table 表名   add constraint 约束名 primary key(列名);--添加外键约束alter table 表名  add constraint 约束名 foreign key(外键名) references 参照表(列名)  --修改列定义alter table 表名modify 列名 int not null;--删除列alter table 表名 drop column 列名;--修改表名ALTER   TABLE   table   RENAME   TO   新表名

热点排行