ALTER [IGNORE] TABLE table_name specification [,specification] : Alter Table « Table « MySQL Tutorial






Specifications can be:

ADD [COLUMN] column name (column definitions) [FIRST or AFTER column_name]
ADD INDEX [index_name] (column_list)
ADD PRIMARY KEY (column_list)
ADD UNIQUE [index_name] (column_list)
ALTER [COLUMN] column_name {SET DEFAULT default_value or DROP DEFAULT}
CHANGE [COLUMN] old_col_name create_definition
DROP [COLUMN] col_name
DROP PRIMARY KEY
DROP INDEX index_name
MODIFY [COLUMN] create_definition
RENAME [AS] new_tbl_name

The IGNORE keyword causes rows with duplicate values in unique keys to be deleted;
otherwise, nothing happens.

ALTER TABLE employee ADD COLUMN Account_Number INT
ALTER TABLE employee ADD INDEX (ID)
ALTER TABLE employee ADD PRIMARY KEY (ID)
ALTER TABLE employee ADD UNIQUE (ID)
ALTER TABLE employee CHANGE ID salary INT
ALTER TABLE employee DROP Customer_ID
ALTER TABLE employee DROP PRIMARY KEY

ALTER TABLE employee DROP INDEX Customer_ID
ALTER TABLE employee MODIFY First_Name varchar(100)
ALTER TABLE employee RENAME Customer








4.3.Alter Table
4.3.1.ALTER [IGNORE] TABLE table_name specification [,specification]
4.3.2.Add primary key to a table by using the alter table command
4.3.3.Drop table column with alter table command
4.3.4.Alter table to add the foreign key
4.3.5.Drop primary key from a table using the alter table command
4.3.6.MODIFYing a TABLE