DML操作

MaxCompute中的DML语句包括插入、更新和删除数据操作。本文为您介绍Dataphin支持的MaxCompute的DML操作语句。

功能

是否支持

插入或覆写数据(INSERT INTO | INSERT OVERWRITE)

  • 支持insert {into|overwrite} table <table_name> [partition (<pt_spec>)] <select_statement> from <from_statement>;

  • 支持指定列插入数据:insert into table <table_name> [partition (<pt_spec>)] (<col_name> ,<col_name> ...) <select_statement> from <from_statement>;

  • 支持插入数据排序。

    insert {into|overwrite} table <table_name> [partition (<pt_spec>)] [(<col_name> [,<col_name> ...)]]
    <select_statement>
    from <from_statement>
    [zorder by <zcol_name> [, <zcol_name> ...]];

插入或覆写动态分区数据(DYNAMIC PARTITION)

多路输出(MULTI INSERT)

VALUES

LOAD

COMMON TABLE EXPRESSION(CTE)

  • 支持with table as (select ...) insert into tab select ... from table

  • 支持with table as (select ...) select ... from table

更新或删除数据(UPDATE | DELETE)

  • 支持update操作用于将Transactional表或Delta Table表中行对应的单列或多列数据更新为新值。

    --方式1
    update <table_name> set <col1_name> = <value1> [, <col2_name> = <value2> ...] [WHERE <where_condition>];
    
    --方式2
    update <table_name> set (<col1_name> [, <col2_name> ...]) = (<value1> [, <value2> ...])[WHERE <where_condition>];
    
    --方式3
    UPDATE <table_name>
           SET <col1_name> = <value1> [ , <col2_name> = <value2> , ... ]
            [ FROM <additional_tables> ]
            [ WHERE <where_condition> ]
  • 支持使用clear column命令清空普通表的列。

    ALTER TABLE <table_name> 
               [partition ( <pt_spec>[, <pt_spec>....] )] 
    					 CLEAR COLUMN column1[, column2, column3, ...]
    			                         [without touch];
  • 支持合并Transactional表文件。

    alter table <table_name> [partition (<partition_key> = '<partition_value>' [, ...])] compact {minor|major};

MERGE INTO

DROP COLUMNS(删除表中列)