ALTER TABLE
Description
ALTER TABLE
statement changes the schema or properties of a table.
RENAME
ALTER TABLE RENAME
statement changes the table name of an existing table in the database.
Syntax
Parameters
table_identifier
-
Specifies a table name, which may be optionally qualified with a database name.
Syntax:[ database_name. ] table_name
partition_spec
-
Partition to be renamed.
Syntax:PARTITION ( partition_col_name = partition_col_val [ , ... ] )
ADD COLUMNS
ALTER TABLE ADD COLUMNS
statement adds mentioned columns to an existing table.
Syntax
Parameters
table_identifier
-
Specifies a table name, which may be optionally qualified with a database name.
Syntax:[ database_name. ] table_name
COLUMNS ( col_spec )
- Specifies the columns to be added to be renamed.
SET AND UNSET
SET TABLE PROPERTIES
ALTER TABLE SET
command is used for setting the table properties. If a particular property was already set,
this overrides the old value with the new one.
ALTER TABLE UNSET
is used to drop the table property.
Syntax
SET SERDE
ALTER TABLE SET
command is used for setting the SERDE or SERDE properties in Hive tables. If a particular property was already set,
this overrides the old value with the new one.
Syntax
SET LOCATION And SET FILE FORMAT
ALTER TABLE SET
command can also be used for changing the file location and file format for
exsisting tables.
Syntax
Parameters
table_identifier
-
Specifies a table name, which may be optionally qualified with a database name.
Syntax:[ database_name. ] table_name
partition_spec
-
Specifies the partition on which the property has to be set.
Syntax:PARTITION ( partition_col_name = partition_col_val [ , ... ] )
SERDEPROPERTIES ( key1 = val1, key2 = val2, ... )
- Specifies the SERDE properties to be set.