ALTER TABLE

Description

Changes the definition of an existing table

Click here to navigate to the PostgreSQL documentation page for this syntax.

It is important to note that the ALTER TABLE statement without the optional ONLY or * can alter other tables because of the possible inheritance that the table could have. For more information about Inheritance between tables, click here.

Grammar Syntax

PostgreSQL provides the ability to create ALTER TABLE with multiple actions, but Snowflake does not, that's why is translated to individual ALTER TABLES.

ALTER TABLE [ IF EXISTS ] [ ONLY ] name [ * ]
    action [, ... ]
ALTER TABLE [ IF EXISTS ] [ ONLY ] name [ * ]
    RENAME [ COLUMN ] column_name TO new_column_name
ALTER TABLE [ IF EXISTS ] [ ONLY ] name [ * ]
    RENAME CONSTRAINT constraint_name TO new_constraint_name
ALTER TABLE [ IF EXISTS ] name
    RENAME TO new_name
ALTER TABLE [ IF EXISTS ] name
    SET SCHEMA new_schema
ALTER TABLE ALL IN TABLESPACE name [ OWNED BY role_name [, ... ] ]
    SET TABLESPACE new_tablespace [ NOWAIT ]
ALTER TABLE [ IF EXISTS ] name
    ATTACH PARTITION partition_name { FOR VALUES partition_bound_spec | DEFAULT }
ALTER TABLE [ IF EXISTS ] name
    DETACH PARTITION partition_name [ CONCURRENTLY | FINALIZE ]

The ALTER TABLE syntax is a grammar that does not fit on just one page, but here is an overview.

Click here to go to the PostgreSQL Standard specification for this syntax.

Navigate to the following pages to get more details about the translation spec for ALTER TABLE syntax.

Last updated