mysql> desc table1;
+-------+----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+----------------+
| id | int | NO | PRI | NULL | auto_increment |
| name | char(20) | NO | | NULL | |
| age | char(33) | NO | | NULL | |
+-------+----------+------+-----+---------+----------------+
#在这里指定id的新类型为int,其他的如自增,自然是删掉了。。
mysql> alter table table1 modify id int;
Query OK, 0 rows affected (0.08 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> desc table1;
+-------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| id | int | NO | PRI | NULL | |
| name | char(20) | NO | | NULL | |
| age | char(33) | NO | | NULL | |
+-------+----------+------+-----+---------+-------+
3 rows in set (0.00 sec)
#删除主键
mysql> alter table table1 drop primary key;
Query OK, 0 rows affected (0.03 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> desc table1;
+-------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| id | int | NO | | NULL | |
| name | char(20) | NO | | NULL | |
| age | char(33) | NO | | NULL | |
+-------+----------+------+-----+---------+-------+
3 rows in set (0.00 sec)
原文:https://www.cnblogs.com/afei654138148/p/15241836.html