Mega Code Archive

 
Categories / MySQL / Table Index
 

Add a sequence column named id to the table

mysql> mysql> CREATE TABLE t     -> (id INT UNSIGNED NOT NULL)     -> TYPE = InnoDB; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> mysql> mysql> ALTER TABLE t     -> ADD id1 INT NOT NULL AUTO_INCREMENT,     -> ADD PRIMARY KEY (id1); Query OK, 0 rows affected (0.01 sec) Records: 0  Duplicates: 0  Warnings: 0 mysql> mysql> SELECT * FROM t ORDER BY id; Empty set (0.00 sec) mysql> mysql> drop table t; Query OK, 0 rows affected (0.00 sec)