Skip to content

Commit

Permalink
docs: add ModifyColumn on nightly (#935)
Browse files Browse the repository at this point in the history
Co-authored-by: Yingwen <[email protected]>
Co-authored-by: Yiran <[email protected]>
  • Loading branch information
3 people authored May 7, 2024
1 parent ceaad68 commit e974911
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
13 changes: 12 additions & 1 deletion docs/nightly/en/reference/sql/alter.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -11,6 +11,7 @@
ALTER TABLE [db.]table
[ADD COLUMN name type [options]
| DROP COLUMN name
| MODIFY COLUMN name type
| RENAME name
]
```
Expand Down Expand Up @@ -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:
Expand Down
13 changes: 12 additions & 1 deletion docs/nightly/zh/reference/sql/alter.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

`ALERT` 可以用来修改表的设置或者表中的数据:

* 添加/删除列
* 添加/删除/修改列
* 重命名表

## Syntax
Expand All @@ -11,6 +11,7 @@
ALTER TABLE [db.]table
[ADD COLUMN name type [options]
| DROP COLUMN name
| MODIFY COLUMN name type
| RENAME name
]
```
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e974911

Please sign in to comment.