The ALTER TABLE statement is used to add, delete, or modify columns in an existing table and also used to add and drop various constraints on an existing table.
Following are the some Alter commands.
(1) To add a column in a table, use the following syntax:
ALTER TABLE table_name ADD column_name datatype;
(2) To delete a column in a table, use the following syntax;
ALTER TABLE table_name DROP COLUMN column_name;
(3) To change the data type of a column in a table, use the following syntax:
ALTER TABLE table_name MODIFY COLUMN column_name datatype;
- 1 like
- 1 comment