docs:mysql:alter_table

ALTER TABLE

ALTER TABLE tablename
(
  ADD|DROP  COLUMN  datatype  [NULL|NOT NULL]  [CONSTRAINTS],
  ADD|DROP  COLUMN  datatype  [NULL|NOT NULL]  [CONSTRAINTS],
  ...
);
  • alter table parcels add primary key (`id`);
  • alter table parcels add key (`area`);
  • alter table parcels add index (`owner`);
  • alter table mytable CONVERT TO CHARACTER SET latin1;
  • alter table mytable CONVERT TO CHARACTER SET latin1 [COLLATE collation_name];
  • alter table mytable type = INNODB;
  • alter table mytable type = MYISAM;
  • 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:25
  • by 127.0.0.1