ALTER TABLE

alter_table

alter_table_action

ALTER TABLE - 图2

alter_table_constraint

ALTER TABLE [ ONLY ] name [ * ] alter_table_action [ , … ]

Alter the specified table and dependencies.

  • ONLY — Limit the change to the specified table.

ADD [ COLUMN ] column_name data_type

Add the specified column with the specified data type.

RENAME TO table_name

Rename the table to the specified table name.

DROP [ COLUMN ] column_name [ RESTRICT | CASCADE ]

Drop the named column from the table.

  • — Remove only the specified

ADD alter_table_constraint

Add the specified constraint to the table. For descriptions of valid table_constraint values, see CREATE TABLE.

DROP CONSTRAINT constraint_name [ RESTRICT | CASCADE ]

  • RESTRICT — Remove only the specified constraint.

RENAME [ COLUMN ] column_name TO column_name

Rename a column to the specified name.

ENABLE / DISABLE ROW LEVEL SECURITY

This enables or disables row level security for the table.If enabled and no policies exist for the table, then a default-deny policy is applied.If disabled, then existing policies for the table will not be applied and will be ignored.See CREATE POLICY for details on how to create row level security policies.

FORCE / NO FORCE ROW LEVEL SECURITY

This controls the application of row security policies for the table when the user is the table owner.If enabled, row level security policies will be applied when the user is the table owner.If disabled (the default) then row level security will not be applied when the user is the table owner.See CREATE POLICY for details on how to create row level security policies.

Specify a table constraint.

CONSTRAINT constraint_name

CHECK ( expression ) | FOREIGN KEY ( column_names ) reference_clause