SQL Alter Table

We can modify the table using the ALTER TABLE command.

Add a Column

SQL syntax

ALTER TABLE table_name
ADD column_name datatype
 

Example SQL Statement

ALTER TABLE Individual
ADD age int
 

Change the Datatype

SQL syntax

ALTER TABLE table_name
ALTER COLUMN column_name datatype
 

Example SQL Statement

ALTER TABLE Individual
ALTER COLUMN age numeric
 

Drop a Column

‘Dropping’ a column means removing or deleting that column.

SQL syntax

ALTER TABLE table_name
DROP COLUMN column_name
 

Example SQL Statement

ALTER TABLE Individual
DROP COLUMN age
 
%d bloggers like this: