Mega Code Archive

 
Categories / MySQL / Table Index
 

To indicate a column at a specific position within the table, either use FIRST to make it the first column, or

AFTER col_name mysql> mysql> CREATE TABLE mytbl     -> (     ->     i INT,     ->     c CHAR(1)     -> ); Query OK, 0 rows affected (0.01 sec) mysql> mysql> ALTER TABLE mytbl DROP i; Query OK, 0 rows affected (0.01 sec) Records: 0  Duplicates: 0  Warnings: 0 mysql> ALTER TABLE mytbl ADD i INT FIRST; Query OK, 0 rows affected (0.01 sec) Records: 0  Duplicates: 0  Warnings: 0 mysql> ALTER TABLE mytbl DROP i; Query OK, 0 rows affected (0.01 sec) Records: 0  Duplicates: 0  Warnings: 0 mysql> ALTER TABLE mytbl ADD i INT AFTER c; Query OK, 0 rows affected (0.01 sec) Records: 0  Duplicates: 0  Warnings: 0 mysql> mysql> drop table mytbl; Query OK, 0 rows affected (0.00 sec)