Modify the definition of appearance.
ALTER FOREIGN TABLE [ IF EXISTS ] name
action [, ... ]
ALTER FOREIGN TABLE [ IF EXISTS ] name
RENAME [ COLUMN ] column_name TO new_column_name
ALTER FOREIGN TABLE [ IF EXISTS ] name
RENAME TO new_name
ALTER FOREIGN TABLE [ IF EXISTS ] name
SET SCHEMA new_schema
The action is as follows:
ADD [ COLUMN ] column_name column_type [ COLLATE collation ] [ column_constraint [ ... ] ]
DROP [ COLUMN ] [ IF EXISTS ] column_name [ RESTRICT | CASCADE ]
ALTER [ COLUMN ] column_name [ SET DATA ] TYPE data_type
ALTER [ COLUMN ] column_name SET DEFAULT expression
ALTER [ COLUMN ] column_name DROP DEFAULT
ALTER [ COLUMN ] column_name { SET | DROP } NOT NULL
ALTER [ COLUMN ] column_name SET STATISTICS integer
ALTER [ COLUMN ] column_name SET ( attribute_option = value [, ... ] )
ALTER [ COLUMN ] column_name RESET ( attribute_option [, ... ] )
ALTER [ COLUMN ] column_name OPTIONS ( [ ADD | SET | DROP ] option ['value'] [, ... ])
DISABLE TRIGGER [ trigger_name | ALL | USER ]
ENABLE TRIGGER [ trigger_name | ALL | USER ]
ENABLE REPLICA TRIGGER trigger_name
ENABLE ALWAYS TRIGGER trigger_name
OWNER TO new_owner
OPTIONS ( [ ADD | SET | DROP ] option ['value'] [, ... ] )
ALTER FOREIGN TABLE Modifies the definition of an existing appearance. The command takes the following forms:
ADD COLUMN
DROP COLUMN [ IF EXISTS ]
IF EXISTS
SET DATA TYPE
SET/DROP DEFAULT
SET/DROP NOT NULL
SET STATISTICS
SET ( attribute_option = value [, ...] ] )
RESET ( attribute_option [, ... ] )
DISABLE/ENABLE [ REPLICA | ALWAYS ] TRIGGER
OWNER
RENAME
SET SCHEMA
OPTIONS ( [ ADD | SET | DROP ] option ['value'] [, ... ] )
You can write all operations except RENAME and SET SCHEMA in a list to allow the YMatrix database to apply these modifications in parallel. For example, you can add multiple columns or modify the attributes of multiple columns in one command.
You must have this table to use the ALTER FOREIGN TABLE operation. In order to modify the appearance pattern, you must also have CREATE permissions in the new mode. To modify the owner, you must be a direct or indirect member of the new role, and that role must have CREATE permissions in the table mode. These restrictions mandate that changing the owner by deleting and recreating the table will not do anything. However, superusers can change ownership of any table anyway. In order to add or modify a column type, you must have USAGE permissions on the data type.
name
column_name
new_column_name
new_name
data_type
CASCADE
RESTRICT
trigger_name
ALL
USER
new_owner
new_schema
Flag a column as NOT NULL:
ALTER FOREIGN TABLE distributors ALTER COLUMN street SET NOT NULL;
Change an exterior option:
ALTER FOREIGN TABLE myschema.distributors
OPTIONS (ADD opt1 'value', SET opt2 'value2', DROP opt3 'value3');
These ADD, DROP and SET DATA TYPE are in the form of the SQL standard. Other forms are extensions of YMatrix databases in the SQL standard. The ability to specify multiple operations in a single ALTER FOREIGN TABLE command is also an extension of the YMatrix database.
You can use ALTER FOREIGN TABLE ... DROP COLUMN to delete the unique column in the table, leaving a table with zero columns. This is also an extension of SQL, allowing the presence of zero columns.