alter
alter 语句用于向已有的表中添加一列。暂不支持更新或删除列。
相关函数:addColumn。
语法
alter table tableObj add columnName columnType;
tableObj 可为任何形式的数据表,包括内存表、流数据表、分布式表或维度表。
colNames 字符串标量,表示要添加的列的名称。
colTypes 表示数据类型的标量。
例子
$ if(existsDatabase("dfs://test")) dropDatabase("dfs://test")
$ create database "dfs://test" partitioned by VALUE(1..10), HASH([SYMBOL, 40]), engine='OLAP', atomic='TRANS', chunkGranularity='TABLE'
$ create table "dfs://test"."pt"(
id INT,
deviceId SYMBOL,
date DATE[comment="time_col", compress="delta"],
value DOUBLE,
isFin BOOL
)
partitioned by ID, deviceID
$ alter table pt add location SYMBOL;
$ pt = loadTable("dfs://test", `pt)
$ pt.schema().colDefs
name |
typeString |
typeInt |
comment |
---|---|---|---|
id |
INT |
4 |
|
deviceId |
SYMBOL |
17 |
|
date |
DATE |
6 |
time_col |
value |
DOUBLE |
16 |
|
isFin |
BOOL |
1 |
|
location |
SYMBOL |
17 |