tencent cloud

Feedback

INSERT OVERWRITE

Last updated: 2024-08-07 17:25:36

    Description

    Supported engines: Presto and SparkSQL
    Applicable table: Native Iceberg tables and external tables
    Purpose: Insert data into the row.
    Note
    Presto supports INSERT OVERWRITE only on partitioned tables of Hive data sources but not on non-partitioned tables and tables of Iceberg data sources.

    Statement

    INSERT OVERWRITE table_identifier [ partition_spec ] [ ( column_list ) ]
    { VALUES ( { value | NULL } [ , ... ] ) [ , ( ... ) ] | query

    Parameter

    table_identifier: Table name in the three-part format. Example: catalog.database.table.
    partition_spec: Partitioning column name and value Example: dt='2021-06-01'
    column_list: All the columns
    query: A general Select query statement.
    1.1 a SELECT statement
    1.2 a TABLE statement

    Example

    -- Insert Using a VALUES Clause
    INSERT OVERWRITE students VALUES
    ('Ashua Hill', '456 Erica Ct, Cupertino', 111111),
    ('Brian Reed', '723 Kern Ave, Palo Alto', 222222);
    
    -- Insert Using a SELECT Statement
    INSERT OVERWRITE students PARTITION (student_id = 222222)
    SELECT name, address FROM persons WHERE name = "Dora Williams"
    
    -- Insert Using a TABLE Statement
    INSERT OVERWRITE students TABLE visiting_students
    
    -- Insert with a column list
    INSERT OVERWRITE students (address, name, student_id) VALUES
    ('Hangzhou, China', 'Kent Yao', 11215016)
    
    -- Insert with both a partition spec and a column list
    INSERT OVERWRITE students PARTITION (student_id = 11215016) (address, name) VALUES
    ('Hangzhou, China', 'Kent Yao Jr.')
    
    
    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 avaliable.

    7x24 Phone Support