tencent cloud

All product documents
Data Lake Compute
ALTER TABLE ADD COLUMNS
Last updated: 2024-08-07 17:14:57
ALTER TABLE ADD COLUMNS
Last updated: 2024-08-07 17:14:57

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;

//The ALTER TABLE PARTITION ADD COLUMNS statement supports only native DLC tables.
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?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon