MySQL Alter Table
Alter table command is used for altering tables, table fields and table indexes
To rename a table:
ALTER TABLE mytable RENAME yourtable;
To add a column:
ALTER TABLE mytable ADD COLUMN update TIMESTAMP FIRST
ALTER TABLE mytable ADD COLUMN update TIMESTAMP AFTER id
ALTER TABLE mytable ADD COLUMN update TIMESTAMP LAST
The first example create a column in the first position. The second command creates a column after the column id. The last example creates a column in the last position.
To drop a column:
ALTER TABLE mytable DROP COLUMN update
To drop an index:
ALTER TABLE mytable DROP INDEX myindex
To modify a column:
ALTER TABLE mytable CHANGE sid sidi INT(10) NOT NULL
We simply specified that the column we wish to modify is sid and then specified its properties.
Technologies: