MySQL ALTER TABLE, DROP TABLE

MySQL Best Practices

To change the structure of a table you use ALTER TABLE statement. This allows you to add or drop column, change data type, rename table etc.

Example of ALTER TABLE:

ALTER TABLE table_name CHANGE COLUMN table_id table_id INT(11) NOT NULL AUTO_INCREMENT;

To remove existing table you need to use DROP TABLE statement as below:

Example of DROP TABLE:

DROP TABLE IF EXISTS table_name;

Leave a Reply

Your email address will not be published. Required fields are marked *