tencent cloud

All product documents
Data Lake Compute
INSERT STATEMENT
Last updated: 2024-08-07 17:25:24
INSERT STATEMENT
Last updated: 2024-08-07 17:25:24
Insert a new row into a table. If a column name list is specified, it must exactly match the column name list output by queries. Columns inserted into a table but not in the column name list will be filled with a null value. If no column name list is specified, the columns output by queries must exactly match those in the target table.

Statement

Presto:
INSERT INTO table_name [ ( column [, ... ] ) ] query
Spark:
INSERT INTO table_identifier [ partition_spec ] [ ( column_list ) ]
{ VALUES ( { value | NULL } [ , ... ] ) [ , ( ... ) ] | query }

Parameter

[ partition_spec ]: Partitioning column name and value Example: dt='2021-06-01'
[ ( column [, ... ] ) ] : All the columns
[table_name] | table_identifier: Table name
[query]: A general Select query statement

Example

Example for Presto and Spark:
INSERT INTO orders SELECT * FROM new_orders;
INSERT INTO cities VALUES (1, 'China');
INSERT INTO nation (nationkey, name, regionkey, comment)
VALUES (26, 'POLAND', 3, 'no comment');
Example for Spark: Use a Select query statement for inserting a column into a partition:
INSERT INTO students PARTITION (student_id = 444444) SELECT name, address FROM persons WHERE name = 'dlc'
Insert a column into a partition:
INSERT INTO students PARTITION (student_id = 11215017) (address, name) VALUES ('Shen zhen, China', 'tester')

Limitations

Presto does not support inserting columns into partitions. You can use Spark instead.

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