ALTER TABLE
Applies to: ❌ Data Cloud SQL ✅ Tableau Hyper API
Change the definition of a table.
where column_constraint
is:
and table_constraint
is as described in CREATE TABLE.
ALTER TABLE
changes the definition of an existing table. Hyper
currently only supports the following changes:
RENAME
The
RENAME
forms change the name of a table, the name of an individual column in a table, or the name of a constraint of the table. There is no effect on the stored data.ADD COLUMN [ IF NOT EXISTS ]
This form adds a new column to the table, using the same syntax as CREATE TABLE. If
IF NOT EXISTS
is specified and a column already exists with this name, no error is thrown. In contrast toCREATE TABLE
, which supports any variable-free expression, including non-constant expressions like random(), the default value here must be a constant.DROP COLUMN [ IF EXISTS ]
This form drops a column from a table. Columns with indexes and table constraints can't be dropped.
ADD table_constraint [ NOT VALID ]
This form adds a new constraint to a table using the same syntax as CREATE TABLE.
Some forms of ALTER TABLE that act on a single table can be combined into a list of multiple alterations to be applied together. It is possible to add several columns and/or drop several columns in a single command. It is also possible to create multiple column constraints in a single command. It is not possible to combine altering columns with adding constraints.
IF EXISTS
Do not throw an error if the table does not exist.
<name>
The name (optionally schema-qualified) of an existing table to alter.
<column_name>
Name of a new or existing column.
<new_column_name>
New name for an existing column.
<new_name>
New name for the table.
<data_type>
Data type of the new column.
The key word COLUMN
is noise and can be omitted.
Changing any part of a system catalog table is not permitted.
To add a column of type text
to a table:
To drop a column from a table:
To rename an existing column:
To rename an existing table:
To add an unnamed assumed foreign key constraint to a table:
See CREATE TABLE for more examples of table constraints.