更新时间:2025-07-24 GMT+08:00

插入数据

本章节主要介绍Doris插入表数据的SQL基本语法和使用说明。

基本语法

INSERT INTO table_name
[ PARTITION (p1, ...) ]
[ WITH LABEL label]
[ (column [, ...]) ]
[ [ hint [, ...] ] ]
{ VALUES ( { expression | DEFAULT } [, ...] ) [, ...] | query }

使用示例

  • 创建test表。
    CREATE TABLE test
    (
    c1 TINYINT,
    c2 DECIMAL(10, 2) DEFAULT "10.5",
    )
    COMMENT "table comment"
    DISTRIBUTED BY HASH(k1) BUCKETS 32;
  • 创建test2。
    CREATE TABLE test2 like test;
  • test表中一次性插入多行数据。
    INSERT INTO test VALUES (1, 2), (3, 4);
  • 查询test2中是否插入数据。
    SELECT * from test2;
  • test表中导入一个查询语句结果。
    INSERT INTO test (c1, c2) SELECT * from test2;