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
old_table_name
- Name of an existing table.
db_name
- Name of the existing database.
new_table_name
- New name using which the table has to be renamed.
partition_spec
- Partition to be renamed.
ADD COLUMNS
ALTER TABLE ADD COLUMNS
statement adds mentioned columns to an existing table.
Syntax
Parameters
table_name
- The name of an existing table.
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_name
- The name of an existing table.
PARTITION (part_spec)
- Specifies the partition on which the property has to be set.
SERDEPROPERTIES (key1=val1, key2=val2, ...)
- Specifies the SERDE properties to be set.