Reference and syntax for the ALTER TABLE command.
Updates the specified table.
Adds a column to an existing table.
Parameter | Description |
---|---|
<table> | Name of the table to which to add the column. |
<column_name> | An identifier that specifies the name of the column that will be added to the table. |
<column_type> | Specifies the data type for the column. |
IF NOT EXISTS | If specified, this clause prevents an error message that would occur if the column already exists in the table. |
| DEFAULT <expression>
| Determines the value that will be used for the column when this column is omitted in an INSERT
statement. It also determines the value that is used for the rows that were inserted before the column was added. |
| NULL
| NOT NULL
| Determines if the column may or may not contain NULL
s. |
The query can only be executed under the following conditions:
CURRENT_DATE()
, LOCALTIMESTAMP()
, CURRENT_TIMESTAMP()
, and NOW()
.Use to delete a partition from a fact or dimension table.
Dropping a partition deletes the partition and the data stored in that partition.
Parameter | Description |
---|---|
<table> | Name of the table from which to drop the partition. |
<value1>[,...<value2>] | An ordered set of one or more values corresponding to the partition key definition. This specifies the partition to drop. When dropping partitions with composite keys (more than one key value), specify all key values in the same order as they were defined. Only partitions with values that match the entire composite key are dropped. |
See the examples in Working with partitions.
Change the owner of a table. The current owner of a table can be viewed in the information_schema.tables
view on table_owner
column.
check ownership page for more info.
Parameter | Description |
---|---|
<table> | Name of the table to change the owner of. |
<user> | The new owner of the table. |
Renames a table.
Parameter | Description |
---|---|
<table_name> | The name of the table to rename. |
<new_table_name> | The new name of the table. |
The query can only be executed under the following conditions: