Renaming a column in a table

suggest change

Renaming a column can be done in a single statement but as well as the new name, the “column definition” (i.e. its data type and other optional properties such as nullability, auto incrementing etc.) must also be specified.

ALTER TABLE `<table name>` CHANGE `<old name>` `<new name>` <column definition>;

Steps:

  1. Open the MySQL command line or a client such as MySQL Workbench.
  2. Run the following statement: SHOW CREATE TABLE <table name>; (replacing <table name> with the relevant value).
  3. Make a note of the entire column definition for the column to be renamed (i.e. everything that appears after the name of the column but before the comma separating it from the next column name).
  4. Replace <old name>, <new name> and <column definition> in the line above with the relevant values and then execute it.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents