tencent cloud

Feedback

DML Statement

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

    INSERT OVERWRITE | INTO

    Row-level data insertion operation

    Statement

    INSERT { OVERWRITE | INTO } [ TABLE ] table_name
    [ PARTITION clause ]
    { VALUES (column_values,...), (column_values,...)...
    | SELECT select_expr}

    Example

    CREATE TABLE IF NOT EXISTS `table_01` (
    `id` INTEGER,
    `num` int,
    `name` STRING
    ) USING `iceberg`
    INSERT INTO table_01 PARTITION(name='21') VALUES (1,2), (2,3);
    INSERT INTO TABLE table_01 VALUES (3,2,'abc'), (4,3,'abd');

    MERGE INTO

    Update data by row (for replacing INSERT OVERWRITE).

    Statement

    MERGE INTO target_table_name [target_alias]
    USING source_table_reference [source_alias]
    ON merge_condition
    [ WHEN MATCHED [ AND condition ] THEN matched_action ] [...]
    [ WHEN NOT MATCHED [ AND condition ] THEN not_matched_action ] [...]
    matched_action
    { DELETE |
    UPDATE SET * |
    UPDATE SET { column1 = value1 } [, ...] }
    not_matched_action
    { INSERT * |
    INSERT (column1 [, ...] ) VALUES (value1 [, ...])

    DELETE FROM

    Statement

    DELETE FROM table_name [table_alias] [WHERE predicate]

    UPDATE

    Support UPDATE operation starting from Spark 3.1.

    Statement

    UPDATE table_identifier [table_alias]
    SET { { column_name | field_name } = expr } [, ...]
    [WHERE clause]

    Example

    UPDATE dempts SET c1 = 'update_c1', c2 = 'update_c2'
    WHERE ts >= '2020-05-01 00:00:00' and ts < '2020-06-01 00:00:00'
    UPDATE dempts SET session_time = 0, ignored = true
    WHERE session_time < (SELECT min(session_time) FROM prod.db.good_events)
    UPDATE dempts AS t1 SET order_status = 'returned'
    WHERE EXISTS (SELECT oid FROM prod.db.returned_orders WHERE t1.oid = oid)
    
    
    
    
    
    
    
    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