ALTER TABLE tablename
<operation> [, <operation>];
<operation> ::=
ADD <col_def>
| ADD <tconstraint>
| DROP colname
| DROP CONSTRAINT constr_name
| DROP SQL SECURITY
| ALTER [COLUMN] colname <col_mod>
| ALTER SQL SECURITY {DEFINER | INVOKER}
| {ENABLE | DISABLE} PUBLICATION
<col_def> ::=
<regular_col_def>
| <computed_col_def>
| <identity_col_def>
<regular_col_def> ::=
colname { <datatype> | domainname }
[DEFAULT {literal | NULL | <context_var>}]
[NOT NULL]
[<col_constraint>]
[COLLATE collation_name]
<computed_col_def> ::=
colname [<datatype>]
{COMPUTED [BY] | GENERATED ALWAYS AS} (<expression>)
<identity_col_def> ::=
colname [<datatype>] {ALWAYS | GENERATED BY} DEFAULT AS IDENTITY
[(START WITH startvalue)] [<col_constraint>]
<col_mod> ::=
TO newname
| POSITION newpos
| <regular_col_mod>
| <computed_col_mod>
| <identity_col_mod>
<regular_col_mod> ::=
| TYPE { <datatype> | domain_name }
| SET DEFAULT {literal | NULL | <context_var>}
| DROP DEFAULT
| SET NOT NULL
| DROP NOT NULL
<computed_col_mod> ::=
[TYPE <datatype>] {GENERATED ALWAYS AS | COMPUTED [BY]} (<expression>)
<identity_col_mod> ::=
<alter identity column option> ...
| SET GENERATED { ALWAYS | BY DEFAULT } [<alter identity column option> ...]
| DROP INDENITY
<alter identity column option> ::=
RESTART [ WITH startvalue ]
| SET INCREMENT [BY] incrementvalue
<datatype> ::=
<scalar_datatype> | <blob_datatype> | <array_datatype>
<scalar_datatype> ::= См. Синтаксис скалярных типов данных
<blob_datatype> ::= См. Синтаксис типа данных BLOB
<array_datatype> ::= См. Синтаксис массивов
<col_constraint> ::=
[CONSTRAINT constr_name]
{ UNIQUE [<using_index>]
| PRIMARY KEY [<using_index>]
| REFERENCES other_table [(other_col)]
[ON DELETE { NO ACTION | CASCADE | SET DEFAULT | SET NULL}]
[ON UPDATE { NO ACTION | CASCADE | SET DEFAULT | SET NULL}]
[<using_index>]
| CHECK (<check_condition>)
}
<tconstraint> ::=
[CONSTRAINT constr_name]
{ UNIQUE (<col_list>) [<using_index>]
| PRIMARY KEY (<col_list>) [<using_index>]
| FOREIGN KEY (<col_list>)
REFERENCES other_table [(<col_list>)]
[ON DELETE { NO ACTION | CASCADE | SET DEFAULT | SET NULL}]
[ON UPDATE { NO ACTION | CASCADE | SET DEFAULT | SET NULL}]
[<using_index>]
| CHECK (<check_condition>)
}
<col_list> ::= colname [, colname ...]
<using_index> ::= USING [ASC[ENDING] | DESC[ENDING]] INDEX indexname
<check_condition> ::=
<val> <operator> <val>
| <val> [NOT] BETWEEN <val> AND <val>
| <val> [NOT] IN (<val> [, <val> ...] | <select_list>)
| <val> IS [NOT] NULL
| <val> IS [NOT] DISTINCT <val>
| <val> IS [NOT] {TRUE | FALSE | UNKNOWN}
| <val> [NOT] CONTAINING <val>
| <val> [NOT] STARTING [WITH] <val>
| <val> [NOT] LIKE <val> [ESCAPE <val>]
| <val> [NOT] SIMILAR TO <val> [ESCAPE <val>]
| <val> <operator> {ALL | SOME | ANY} (<select_list>)
| [NOT] EXISTS (<select_expr>)
| [NOT] SINGULAR (<select_expr>)
| (<check_condition>)
| NOT <check_condition>
| <check_condition> OR <check_condition>
| <check_condition> AND <check_condition>
<operator> ::=
<> | != | ^= | ~= | = | < | > | <= | >=
| !< | ^< | ~< | !> | ^> | ~>
<val> ::=
colname [[<array_idx> [, <array_idx> ...]]]
| literal
| <context_var>
| <expression>
| NULL
| NEXT VALUE FOR genname
| GEN_ID(genname, <val>)
| CAST(<val> AS <datatype>)
| (<select_one>)
| func(<val> [, <val> ...])
<cast_type> ::=
<datatype>
| [TYPE OF] domain_name
| TYPE OF COLUMN rel.colname