diff --git a/docs/nightly/en/reference/sql/alter.md b/docs/nightly/en/reference/sql/alter.md index ce2f04252..9ab2d64f0 100644 --- a/docs/nightly/en/reference/sql/alter.md +++ b/docs/nightly/en/reference/sql/alter.md @@ -2,7 +2,7 @@ `ALERT` can be used to modify any table settings or data within the table: -* Add/Drop a column +* Add/Drop/Modify a column * Rename a table ## Syntax @@ -11,6 +11,7 @@ ALTER TABLE [db.]table [ADD COLUMN name type [options] | DROP COLUMN name + | MODIFY COLUMN name type | RENAME name ] ``` @@ -54,6 +55,16 @@ ALTER TABLE monitor DROP COLUMN load_15; The removed column can't be retrieved immediately by all subsequent queries. +### Modify column type + +Modify the date type of a column + +```sql +ALTER TABLE monitor MODIFY COLUMN load_15 STRING; +``` + +The modified column cannot be a tag (primary key) or time index, and it must be nullable to ensure that the data can be safely converted (returns `NULL` on cast failures). + ### Rename table Renames the table: diff --git a/docs/nightly/zh/reference/sql/alter.md b/docs/nightly/zh/reference/sql/alter.md index 1708c0c28..08966d6ae 100644 --- a/docs/nightly/zh/reference/sql/alter.md +++ b/docs/nightly/zh/reference/sql/alter.md @@ -2,7 +2,7 @@ `ALERT` 可以用来修改表的设置或者表中的数据: -* 添加/删除列 +* 添加/删除/修改列 * 重命名表 ## Syntax @@ -11,6 +11,7 @@ ALTER TABLE [db.]table [ADD COLUMN name type [options] | DROP COLUMN name + | MODIFY COLUMN name type | RENAME name ] ``` @@ -55,6 +56,16 @@ ALTER TABLE monitor DROP COLUMN load_15; 后续的所有查询立刻不能获取到被移除的列。 +### 修改列类型 + +修改列的数据类型 + +```sql +ALTER TABLE monitor MODIFY COLUMN load_15 STRING; +``` + +被修改的的列不能是 tag 列(primary key)或 time index 列,同时该列必须允许空值 `NULL` 存在来保证数据能够安全地进行转换(转换失败时返回 `NULL`)。 + ### 重命名表 ```sql