设置自增长:
alter table table1 add id int auto_increment primary key 自增字段,id一定要设置为primary key.
alter table users AUTO_INCREMENT=10000;
添加删除外键:
ALTER TABLE articles DROP FOREIGN KEY fk_member;
alter table tb_active add constraint FK_ID foreign key(user_id) REFERENCES tb_user(id)
alter table table1 add id int auto_increment primary key 自增字段,id一定要设置为primary key.
alter table users AUTO_INCREMENT=10000;
添加删除外键:
ALTER TABLE articles DROP FOREIGN KEY fk_member;
alter table tb_active add constraint FK_ID foreign key(user_id) REFERENCES tb_user(id)
本文介绍了如何使用SQL语句来修改表结构,包括添加自增长字段、设置自增起始值、添加及删除外键约束等操作。通过具体示例展示了ALTER TABLE语句的用法。
5万+

被折叠的 条评论
为什么被折叠?



