Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== ALTER TABLE ====== * http://dev.mysql.com/doc/refman/4.1/en/alter-table.html ===== Standard Syntax ===== <code sql> ALTER TABLE tablename ( ADD|DROP column datatype [NULL|NOT NULL] [CONSTRAINTS], ADD|DROP column datatype [NULL|NOT NULL] [CONSTRAINTS], ... ); </code> ===== Adding a Primary Key ===== * alter table parcels add primary key (`id`); ===== Adding an Index/Key ===== * alter table parcels add key (`area`); * alter table parcels add index (`owner`); ===== Converting to a Character Set ===== * alter table mytable CONVERT TO CHARACTER SET latin1; * alter table mytable CONVERT TO CHARACTER SET latin1 [COLLATE collation_name]; ===== Converting to a different engine ===== * alter table mytable type = INNODB; * alter table mytable type = MYISAM; ===== Renaming a Column ===== * alter table weeks change status_id status_type_id int(2) not null; * table name: weeks * old column name: status_id * new column name: status_type_id docs/mysql/alter_table.txt Last modified: 2008/08/03 00:25by 127.0.0.1