PostgreSQL DROP COLUMN Keyword
The PostgreSQL DROP COLUMN keyword is used to a delete columns from an existing table.
Syntax
The syntax for using DROP COLUMN keyword to drop columns in PostgreSQL is given below:
ALTER TABLE table_name DROP COLUMN column_name;
Example:
Consider a database table called Employee with the following records:
EmpID | Name | City | Age |
---|---|---|---|
1 | John | London | 25 |
2 | Marry | New York | 24 |
3 | Jo | Paris | 27 |
4 | Kim | Amsterdam | 30 |
DROP COLUMN
To drop the Salary column from the Employee table, the following statement can be used:
ALTER TABLE Employee DROP COLUMN Age;
This will produce the below mentioned result:
EmpID | Name | City |
---|---|---|
1 | John | London |
2 | Marry | New York |
3 | Jo | Paris |
4 | Kim | Amsterdam |
❮ PostgreSQL Keywords