JOAOSANTACRUZ.COM

How to move columns in MySQL tables?

How to change columns order in a MySQL table


						

# Puts 'code' AFTER 'id' column

ALTER TABLE departments MODIFY COLUMN `code` VARCHAR(50) AFTER `id`; 

 

# Puts 'id' column in the begining of the table structure

ALTER TABLE sales MODIFY `id` int(11) NOT NULL FIRST;

 

Go Back