Mysql Tips #1: Change field order and insert

Change the field orderĀ 

Sometimes we want to change the field order without deleting and re-inserting.
ALTER TABLE `table_name` MODIFY `column_you_want_to_move` DATATYPE AFTER `column`

ALTER TABLE `investment_security` MODIFY `location` text AFTER `serial_number`;

If you want to move it to the first place then:

ALTER TABLE `investment_security` MODIFY `location` text FIRST;

 

Insert from one table into another

INSERT INTO new_table SELECT columns-in-new-order FROM old_table;

Happy coding!!!!!