After using PowerDesigner to design the database, import it into navicat and find that the primary key cannot be set to auto-increment. How to solve it?
1833 - Cannot change column ‘id’:used in a foreign key constraint ‘FK_Relationship_3’ of table ‘hotelmanagesystem.orderlist’
1.
set foreign_key_checks = 0;
ALTER TABLE tablename MODIFY COLUMN id int(11) NOT NULL AUTO_INCREMENT FIRST;
Each table can be executed in turn
As shown in the figure, it can run successfully:
2. I found that if you do not use powerdesigner to import, if you design directly in navicat, you can directly add auto-increment to the primary key as the foreign key.
Reference blog post: https://blog.csdn.net/weixin_41779914/article/details/108188233