The ALTER TABLE statement is used to add, delete, or modify columns in an existing table. ALTER TABLE also comes under Data Definition language (DDL)
Add Column
Syntax:
Add Column
Syntax:
ALTER TABLE table_name
ADD column_name datatype
Example
ALTER TABLE Customer
ADD Location varchar(50);
Drop Column
Syntax
ALTER TABLE table_name
DROP COLUMN column_name
Example
ALTER TABLE Customer
Drop Location varchar(50);
Change DataType
Syntax
ALTER TABLE table_name
ALTER COLUMN column_name datatype
Example
ALTER TABLE Customer
Drop Location varchar(30);
No comments:
Post a Comment