Description
Supported engines: Presto and SparkSQL
Applicable table: Native Iceberg tables and external tables
Purpose: Change data table attributes.
Standard Statement
ALTER TABLE table_name
[PARTITION
(partition_col1_name = partition_col1_value
[,partition_col2_name = partition_col2_value][,...])]
ADD COLUMNS (col_name data_type) [RESTRICT | CASCADE]
Parameter
table_name
: Name of the target table
partition_col1_name
: Partitioning column name
partition_col1_value
: Partitioning column value
col_name
: Name of the column to be added.
data_type
: Type of the column to be added.
Example
ALTER TABLE events ADD COLUMNS (eventowner string);
ALTER TABLE events ADD COLUMNS (eventowner string) CASCADE;
ALTER TABLE events PARTITION (year='2021') ADD COLUMNS (event string);
Caution
If you use the ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe'
format during table creation, you cannot add columns after the table is created. If you use JsonSerDe to create a table, confirm the table structure if possible. If you must add columns, you can delete the existing table and create a new one.
Was this page helpful?