DML operations

Updated at:

Data Manipulation Language (DML) statements in MaxCompute are used to insert, update, and delete data. This topic describes the MaxCompute DML statements supported by Dataphin.

Function

Supported

Insert or overwrite data (INSERT INTO | INSERT OVERWRITE)

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

  • Inserting data into specified columns: insert into table {table_name} [partition ({pt_spec})] ({col_name} ,{col_name} ...) {select_statement} from {from_statement};

  • Sorting data during insertion:

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

Insert or overwrite data into dynamic partitions (DYNAMIC PARTITION)

Yes

Multi insert (MULTI INSERT)

Yes

VALUES

Yes

LOAD

No

Common table expression (CTE)

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

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

  • with table as (select ...) merge into tab using table on ...

Update or delete data (UPDATE | DELETE)

  • Use the update operation to update columns in a transactional table or a Delta table.

    --Syntax 1
    update <table_name> set <col1_name> = <value1> [, <col2_name> = <value2> ...] [WHERE <where_condition>];
    
    --Syntax 2
    update <table_name> set (<col1_name> [, <col2_name> ...]) = (<value1> [, <value2> ...])[WHERE <where_condition>];
    
    --Syntax 3
    UPDATE <table_name>
           SET <col1_name> = <value1> [ , <col2_name> = <value2> , ... ]
            [ FROM <additional_tables> ]
            [ WHERE <where_condition> ]
  • Use the clear column command to clear columns in a standard table.

    ALTER TABLE <table_name> 
               [partition ( <pt_spec>[, <pt_spec>....] )] 
    					 CLEAR COLUMN column1[, column2, column3, ...]
    			                         [without touch];
  • Compacting files for a transactional table:

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

MERGE INTO

Yes

Drop columns (delete columns from a table)

Yes