Book Contents

Book Index

Next Topic

Home

ALTER TABLE

Adds or drops a single column or a table constraint from the metadata of a table.

Syntax

ALTER TABLE table-name

{

ADD COLUMN column-definition

| ADD table-constraint

| DROP CONSTRAINT constraint-name

}

Semantics

table-name

specifies the name of the table to be altered

ADD COLUMN

column-definition

adds a new column to a table and to all superprojections of the table. A unique projection column name is generated in each superprojection. The column is populated according to the column-constraint.

ADD

table-constraint

adds a table constraint (see table-constraint) to a table that does not have any associated projections.

DROP CONSTRAINT

constraint-name

drops the specified table-constraint from a table that does not have any associated projections.

Notes

Example

ALTER TABLE Product_Dimension

ADD CONSTRAINT PK_Product_Dimension PRIMARY KEY (Product_Key);

SQL Language References

PostgreSQL 8.0.12 Documentation

BNF Grammar for SQL-99

In This Section

table-constraint