tencent cloud

Data Lake Compute

INSERT INTO

PDF
フォーカスモード
フォントサイズ
最終更新日: 2025-12-25 12:00:06

説明

サポートカーネル:Presto、SparkSQL。
適用テーブル範囲:ネイティブIcebergテーブル、外部テーブル。
用途:ソーステーブルで実行されるSELECTクエリの結果を新しい行としてターゲットテーブルに挿入することをサポートします。

構文

[ WITH with_query [ , ... ] ]
INSERT {INTO [<TABLE>]| TABLE} table_identifier [ partition_spec ] [ ( column_list ) ]
{ VALUES ( { value | NULL } [ , ... ] ) [ , ( ... ) ] | query }

パラメータ

table_identifier:テーブル名を指定します。三段式(例:catalog.database.table)がサポートされています。
partition_spec:パーティション列と値。例:dt='2021-06-01'。
column_list:列の一覧。
query:汎用Selectクエリ文。     
1.1 a SELECT statement
1.2 a TABLE statement

INSERT INTO orders SELECT * FROM new_orders;
INSERT INTO cities VALUES (1, 'China');
INSERT INTO nation (nationkey, name, regionkey, comment)
VALUES (26, 'POLAND', 3, 'no comment');

-- INSERT INTO partition
INSERT INTO students PARTITION (student_id = 444444) SELECT name, address FROM persons WHERE name = 'dlc'
INSERT INTO students PARTITION (student_id = 11215017) (address, name) VALUES ('Shen zhen, China', 'tester')

-- Insert Using a TABLE Statement
INSERT INTO students TABLE visiting_students;

-- with
WITH `tmp1` AS ((SELECT *
FROM `catalog1`.`db1`.`tbl1`)), `tmp2` AS ((SELECT *
FROM `tbl2`))
INSERT INTO `catalog1`.`db2`.`tbl1`
(SELECT `col1`, `col2`
FROM `tmp1` `a`
INNER JOIN `tmp2` `b` ON `a`.`col1` = `b`.`col2`)


INSERT INTO `catalog1`.`db2`.`tbl1`
WITH `tmp1` AS ((SELECT *
FROM `catalog1`.`db1`.`tbl1`)), `tmp2` AS ((SELECT *
FROM `tbl2`))
(SELECT `col1`, `col2`
FROM `tmp1` `a`
INNER JOIN `tmp2` `b` ON `a`.`col1` = `b`.`col2`)


ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック