ALTER TABLE

Description

Changes the definition of an existing table

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

Only perform the operation on the table name specified. If the ONLY keyword is not used, the operation will be performed on the named table and any child table partitions associated with that table. For more information about Inheritance between tables, click here.

Grammar Syntax

Greenplum 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] [ONLY] <name> SET
   [ WITH (reorganize=true|false) ]
     DISTRIBUTED BY ({<column_name> [<opclass>]} [, ... ] )
   | DISTRIBUTED RANDOMLY
   | DISTRIBUTED REPLICATED 

ALTER TABLE <name>
   [ ALTER PARTITION { <partition_name> | FOR (RANK(<number>)) 
   | FOR (<value>) } [...] ] <partition_action>

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 Greenplum Standard specification for this syntax.

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

If there's an alter action missing, consult the PostgreSQL ALTER TABLE.

Last updated