mysql> alter table tt change id id int default null;
Query OK, 1 row affected (0.23 sec)
Records: 1 Duplicates: 0 Warnings: 0
mysql> show create table tt;
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table
|
| tt | CREATE TABLE `tt` (
`id` int(11) NOT NULL DEFAULT "0",
`Field1` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
1 row in set (0.02 sec)
mysql> alter table tt modify id int not null auto_increment;
Query OK, 1 row affected (0.20 sec)
mysql> select * from tt;
+----+--------+
| id | Field1 |
| 1 | 華人 |
mysql> alter table tt change id id int default null;
Query OK, 1 row affected (0.23 sec)
Records: 1 Duplicates: 0 Warnings: 0
mysql> show create table tt;
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table
|
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| tt | CREATE TABLE `tt` (
`id` int(11) NOT NULL DEFAULT "0",
`Field1` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.02 sec)
mysql> alter table tt modify id int not null auto_increment;
Query OK, 1 row affected (0.20 sec)
Records: 1 Duplicates: 0 Warnings: 0
mysql> select * from tt;
+----+--------+
| id | Field1 |
+----+--------+
| 1 | 華人 |
+----+--------+