Updated on 2024-07-04 GMT+08:00

Inserting Data to a DCS Table

Function

This statement is used to insert data in a DLI table to the DCS key.

Syntax

  • Insert the SELECT query result into a table.
    1
    2
    3
    4
    5
    6
    7
    INSERT INTO DLI_TABLE
      SELECT field1,field2...
      [FROM DLI_TEST]
      [WHERE where_condition]
      [LIMIT num]
      [GROUP BY field]
      [ORDER BY field] ...;
    
  • Insert a data record into a table.
    1
    2
    INSERT INTO DLI_TABLE
      VALUES values_row [, values_row ...];
    

Keywords

For details about the SELECT keywords, see Basic Statements.

Parameters

Table 1 Parameters

Parameter

Description

DLI_TABLE

Name of the DLI table for which a datasource connection has been created.

DLI_TEST

indicates the table that contains the data to be queried.

field1,field2..., field

Column values in the DLI_TEST table must match the column values and types in the DLI_TABLE table.

where_condition

Query condition.

num

Limit the query result. The num parameter supports only the INT type.

values_row

Value to be inserted to a table. Use commas (,) to separate columns.

Precautions

  • A DLI table is available.
  • When creating a DLI table, you need to specify the schema information.
  • If key.column is specified during table creation, the value of the specified field is used as a part of the Redis key name. The following is an example:
    1
    2
    3
    4
    5
    6
    7
    8
    create table test_redis(name string, age int) using redis options(
      'host' = '192.168.4.199',
      'port' = '6379',
      'passwdauth' = '******',
      'table' = 'test_with_key_column',
      'key.column' = 'name'
    );
    insert into test_redis values("James", 35), ("Michael", 22);
    

    The Redis database contains two tables, naming test_with_key_column:James and test_with_key_column:Michael respectively.

  • If key.column is not specified during table creation, the key name in Redis uses the UUID. The following is an example:
    1
    2
    3
    4
    5
    6
    7
    create table test_redis(name string, age int) using redis options(
      'host' = '192.168.7.238',
      'port' = '6379',
      'passwdauth' = '******',
      'table' = 'test_without_key_column'
    );
    insert into test_redis values("James", 35), ("Michael", 22);
    

    In Redis, there are two tables named test_without_key_column:uuid.

Example

1
2
INSERT INTO test_redis
  VALUES("James", 35), ("Michael", 22);