mysql> alter table newcar change id id int(11) not null AUTO_INCREMENT;
Query OK, 10 rows affected (0.16 sec)
Records: 10 Duplicates: 0 Warnings: 0
mysql> alter table newcar change id id int(11);
Query OK, 10 rows affected (0.17 sec)
Records: 10 Duplicates: 0 Warnings: 0
mysql> alter table newcar drop primary key;
Query OK, 10 rows affected (0.13 sec)
Records: 10 Duplicates: 0 Warnings: 0
mysql> alter table newcar add primary key(id);
Query OK, 10 rows affected (0.16 sec)
Records: 10 Duplicates: 0 Warnings: 0
mysql> alter table newcar change id id int(11) not null AUTO_INCREMENT;
Query OK, 10 rows affected (0.19 sec)
Records: 10 Duplicates: 0 Warnings: 0
Query OK, 10 rows affected (0.16 sec)
Records: 10 Duplicates: 0 Warnings: 0
mysql> alter table newcar change id id int(11);
Query OK, 10 rows affected (0.17 sec)
Records: 10 Duplicates: 0 Warnings: 0
mysql> alter table newcar drop primary key;
Query OK, 10 rows affected (0.13 sec)
Records: 10 Duplicates: 0 Warnings: 0
mysql> alter table newcar add primary key(id);
Query OK, 10 rows affected (0.16 sec)
Records: 10 Duplicates: 0 Warnings: 0
mysql> alter table newcar change id id int(11) not null AUTO_INCREMENT;
Query OK, 10 rows affected (0.19 sec)
Records: 10 Duplicates: 0 Warnings: 0
本文记录了MySQL中对newcar表进行的一系列结构修改操作,包括更改id字段为自增、移除主键及重新添加主键等过程。通过这些操作展示了如何在MySQL中灵活调整表结构。
4563

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



