tencent cloud

文档反馈

DML 语法

最后更新时间:2024-08-07 17:28:42

    INSERT OVERWRITE | INTO

    行级数据插入操作

    语法

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

    示例

    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

    行级数据更新操作,可用于替换 INSERT OVERWRITE 操作

    语法

    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

    语法

    DELETE FROM table_name [table_alias] [WHERE predicate]

    UPDATE

    从Spark 3.1起支持UPDATE操作

    语法

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

    示例

    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)
    
    
    
    
    
    
    联系我们

    联系我们,为您的业务提供专属服务。

    技术支持

    如果你想寻求进一步的帮助,通过工单与我们进行联络。我们提供7x24的工单服务。

    7x24 电话支持