field

MySQL Rename Field

To rename a field, there are loads of examples and different syntax on the web, so I thought I would blog the only one that works for me:

ALTER TABLE <table_name>
    CHANGE COLUMN <field_name> <new_field_name>;

I think you have to specify the field type even if you aren’t changing it.

ALTER TABLE clients
    CHANGE COLUMN telephone telephonenumber
    VARCHAR(40) DEFAULT NULL;