tencent cloud

Data Lake Compute

製品概要
プロダクト概要
製品の強み
適用シーン
購入ガイド
課金概要
返金説明
支払い期限切れ説明
設定調整費用の説明
クイックスタート
新規ユーザー開通フルプロセス
DLC データインポートガイド
DLCデータ分析の1分間入門
DLC権限管理の1分間入門
パーティションテーブル1分間入門
データ最適化をオンにする
クロスソース分析 EMR Hive データ
標準エンジン構成ガイド
操作ガイド
コンソール操作紹介
開発ガイド
実行環境
SparkJar ジョブ開発ガイド
PySparkジョブ開発ガイド
「クエリパフォーマンス最適化ガイド」
UDF 関数開発ガイド
システム制約
クライアントアクセス
JDBCアクセス
TDLC コマンドラインツールにアクセス
サードパーティソフトウェア連携
Python にアクセス
実践チュートリアル
DLC を Power BI に接続
テーブル作成の実践
Apache Airflowを使用してDLCエンジンのタスクをスケジュールして送信する
StarRocks は DLC 内部ストレージを直接クエリします
Spark の計算コスト最適化プラクティス
DATA + AI
ロールSSOを使用してDLCにアクセスする
SQL構文
SuperSQL構文
標準 Spark 構文概要
標準 Presto 構文の概要
予約語
API Documentation
History
Introduction
API Category
Making API Requests
Data Table APIs
Task APIs
Metadata APIs
Service Configuration APIs
Permission Management APIs
Database APIs
Data Source Connection APIs
Data Optimization APIs
Data Engine APIs
Resource Group for the Standard Engine APIs
Data Types
Error Codes
一般クラスリファレンス
エラーコード
クォータと制限
サードパーティソフトウェアでDLCに接続する操作ガイド
よくあるご質問
権限に関するよくあるご質問
エンジン類のよくある質問
機能に関するよくあるご質問
Sparkジョブクラスに関するよくある質問
DLC ポリシー
プライバシーポリシー
データプライバシーとセキュリティ契約
お問い合わせ

DDL 構文

PDF
フォーカスモード
フォントサイズ
最終更新日: 2025-12-25 12:00:06
説明:
以下の構文説明はDLCネイティブテーブルの構文であり、DLCネイティブテーブルはデフォルトでIcebergテーブルです。Iceberg外部テーブルを使用する場合、DDL構文に細かい違いがありますので、ドキュメントIceberg外部テーブルとネイティブテーブルの構文の違いを参照してください。

CREATE TABLE

構文

CREATE TABLE [ IF NOT EXISTS ] table_identifier
( col_name[:] col_type [ COMMENT col_comment ], ... )
[ COMMENT table_comment ]
[ PARTITIONED BY ( col_name1, transform(col_name2), ... ) ]

パラメータ

table_identifier

table_identifier は三段式をサポートしています:catalog.db.name

Schemas and Data Types

col_type
: primitive_type
  | nested_type
primitive_type
: boolean
| int/integer
| long/bigint
| float
| double
| decimal(p,s),p=最大桁数,s=最大小数点桁数, s<=p<=38
| date
| timestamptimestamp with timezone,timeとwithout timezoneはサポートされていません
| string,Icebergのuuidタイプにも対応可能
| binary,Icebergのfixedタイプにも対応可能
nested_type
: struct
| list
| map

Partition Transforms

transform
: identity,任意のタイプをサポート, DLCはこの変換をサポートしていません
| bucket[N]、ハッシュmod Nバケット、col_typeをサポート: int、long、decimaldatetimestamp、string、binary
| truncate[L],Lによるバケット分割の切り捨て、サポートされるcol_type: int,long,decimal,string
| years,年、サポートされるcol_type: date,timestamp
| months,月、サポートされるcol_type: date,timestamp
| days/date,日付、サポートされるcol_type: date,timestamp
hours/date_hour,時間,col_type: timestampをサポート

CREATE TABLE dempts(
id bigint COMMENT 'id number',
num int,
eno float,
dno double,
cno decimal(9,3),
flag  boolean,
data string,
ts_year timestamp,
date_month date,
bno binary,
point struct<x: double, y: double>,
points array<struct<x: double, y: double>>,
pointmaps map<struct<x: int>, struct<a: int>>
)
COMMENT 'table documentation'
PARTITIONED BY (bucket(16,id), years(ts_year), months(date_month), identity(bno), bucket(3,num),truncate(10,data));

CREATE TABLE AS SELECT

構文構造

CREATE TABLE [ IF NOT EXISTS ] table_identifier
[ COMMENT table_comment ]
[ PARTITIONED BY ( col_name1, transform(col_name2), ... ) ]
[ TBLPROPERTIES ( property_name=property_value, ... ) ]
AS select_statement

CREATE TABLE dempts_copy
COMMENT 'table create as select'
PARTITIONED BY (eno, dno)
AS SELECT * from dempts;

REPLACE TABLE AS SELECT

テーブルの履歴 History を保持したまま、SELECT クエリの結果を使用してスナップショット Snapshot を生成し、テーブルを更新します。

構文構造

CREATE [OR REPLACE] TABLE table_identifier
[ COMMENT table_comment ]
[ PARTITIONED BY ( col_name1, transform(col_name2), ... ) ]
AS select_statement

CREATE OR REPLACE TABLE dempts_replace
COMMENT 'table create as replace'
PARTITIONED BY (eno, dno)
AS SELECT * from dempts;

DROP TABLE

構文構造

DROP TABLE [ IF EXISTS ] table_identifier

ALTER TABLE

テーブル構文の変更

ALTER TABLE ... RENAME TO

テーブル名の変更

構文構造

ALTER TABLE table_identifier RENAME TO new_table_identifier

ALTER TABLE ... SET / UNSET TBLPROPERTIES 

テーブルプロパティの更新/削除

構文構造

-- SET プロパティ構成の更新
ALTER TABLE table_identifier
SET TBLPROPERTIES (property_name=property_value, ...)

-- UNSET プロパティ構成の削除
ALTER TABLE table_identifier
UNSET TBLPROPERTIES (property_name, ...)

-- SET プロパティ構成の更新
ALTER TABLE dempts SET TBLPROPERTIES ('read.split.target-size'='268435456');

-- UNSET プロパティ構成の削除
ALTER TABLE dempts UNSET TBLPROPERTIES ('read.split.target-size'='268435456');


ALTER TABLE ... WRITE ORDERED BY

テーブルデータ挿入時のソート方法を設定

構文構造

ALTER TABLE table_identifier 
WRITE [LOCALLY] ORDERED BY 
{col_name [ASC|DESC] [NULLS FIRST|LAST]}[, ...]

ALTER TABLE dempts WRITE ORDERED BY category, id;

-- use optional ASC/DEC keyword to specify sort order of each field (default ASC)
ALTER TABLE dempts WRITE ORDERED BY category ASC, id DESC;

-- use optional NULLS FIRST/NULLS LAST keyword to specify null order of each field (default FIRST)
ALTER TABLE dempts WRITE ORDERED BY category ASC NULLS LAST, id DESC NULLS FIRST;

-- To order within each task, not across tasks
ALTER TABLE dempts WRITE LOCALLY ORDERED BY category, id;

ALTER TABLE ... WRITE DISTRIBUTED BY PARTITION

パーティションテーブルのデータ配分戦略を変更

構文

ALTER TABLE table_identifier 
WRITE DISTRIBUTED BY PARTITION 
[ LOCALLY ORDERED BY 
{col_name [ASC|DESC] [NULLS FIRST|LAST]}[, ...]] 

ALTER TABLE dempts WRITE DISTRIBUTED BY PARTITION;
ALTER TABLE dempts WRITE DISTRIBUTED BY PARTITION LOCALLY ORDERED BY id;

ALTER TABLE COLUMNS

フィールド構文の変更

ALTER TABLE ... ADD COLUMNS

複数フィールドの追加

構文

-複数フィールドの追加
ALTER TABLE table_identifier 
ADD COLUMNS (col_name col_type [COMMENT col_comment], ...)

-- 単一フィールドの追加
ALTER TABLE table_identifier 
ADD COLUMN col_name col_type [COMMENT col_comment] 
[FIRST | AFTER target_col_name]

-複数フィールドの追加
ALTER TABLE dempts
ADD COLUMNS (
new_column_1 string comment 'new_column_1 docs',
new_column_2 int comment 'new_column_2 docs'
);

-- 単一フィールドの追加
ALTER TABLE dempts 
ADD COLUMN new_column_3 string comment 'new_column docs';

ALTER TABLE ... RENAME COLUMN 

フィールド名の変更

構文

ALTER TABLE table_identifier 
RENAME COLUMN old_column_name TO new_column_name

ALTER TABLE ... ALTER COLUMN

フィールドのタイプ/備考情報の変更

構文

ALTER TABLE table_identifier 
ALTER COLUMN col_name 
{TYPE new_col_type | COMMENT col_comment}
現在、Iceberg TYPEの変更は、フィールドタイプの安全な拡張のみをサポートしています:
int/integer -> long/bigint
float -> double
decimal(P,S) → decimal(P2,S)、ただしP2 > P、つまり精度が向上

ALTER TABLE dempts ALTER COLUMN new_column_2 TYPE bigint;
ALTER TABLE dempts ALTER COLUMN new_column_2 comment 'alter docs';

ALTER TABLE ... DROP COLUMN

テーブルフィールドを削除

構文構造

ALTER TABLE table_identifier DROP COLUMN column_name

ALTER TABLE PARTITIONS

ALTER TABLE ... ADD PARTITION FIELD

単一パーティションフィールドの追加

構文構造

ALTER TABLE table_identifier 
ADD PARTITION FIELD col_name|transform (col_name) [AS alias]
transform はCREATE TABLEの説明を参照してください。

ALTER TABLE dempts ADD PARTITION FIELD new_column_1;
ALTER TABLE dempts ADD PARTITION FIELD bucket(3,new_column_2);

ALTER TABLE ... REPLACE PARTITION FIELD

単一パーティションフィールドの置換

構文構造

ALTER TABLE table_identifier REPLACE PARTITION FIELD col_name|transform (col_name) [AS alias]

ALTER TABLE ... DROP PARTITION FIELD

単一パーティションフィールドを削除

構文構造

ALTER TABLE table_identifier 
DROP PARTITION FIELD col_name|transform (col_name);
transform はCREATE TABLEの説明を参照してください。

ALTER TABLE dempts DROP PARTITION FIELD new_column_1;
ALTER TABLE dempts DROP PARTITION FIELD bucket(3,new_column_2);

ALTER TABLE ... SET IDENTIFIER FIELDS 

identifier fields 属性を追加する

構文構造

ALTER TABLE dempts SET IDENTIFIER FIELDS empno, name

ALTER TABLE .. DROP IDENTIFIER FIELDS

identifier fields 属性を追加する

構文構造


ALTER TABLE dempts DROP IDENTIFIER FIELDS empno, name


ヘルプとサポート

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

フィードバック