Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add unset option syntax in alter table #1315

Merged
merged 4 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions docs/reference/sql/alter.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ALTER TABLE [db.]table
| MODIFY COLUMN name UNSET FULLTEXT
| RENAME name
| SET <option_name>=<option_value> [, ...]
| UNSET <option_name>[, ...]
]
```

Expand Down Expand Up @@ -97,6 +98,12 @@ ALTER TABLE monitor SET 'compaction.twcs.max_active_window_runs'='6';
ALTER TABLE monitor SET 'compaction.twcs.max_inactive_window_runs'='6';
```

#### Unset options:

```sql
ALTER TABLE monitor UNSET 'ttl';
```

### Modify column fulltext index options

Enable fulltext index on a column:
Expand All @@ -112,15 +119,15 @@ You can specify the following options using `FULLTEXT WITH` when enabling fullte

If `WITH <options>` is not specified, `FULLTEXT` will use the default values.

Disable fulltext index on a column:
#### Disable fulltext index on a column

```sql
ALTER TABLE monitor MODIFY COLUMN load_15 UNSET FULLTEXT;
```

The column must be a string type to alter the fulltext index.

When the fulltext index is disabled, you can enable it and specify the `analyzer` and `case_sensitive` options. When the fulltext index is already enabled on a column, you can disable it but cannot modify the options.
If the fulltext index has never been enabled, you can enable it and specify the `analyzer` and `case_sensitive` options. When the fulltext index is already enabled on a column, you can disable it but **cannot modify the options**.

### Rename table

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ALTER TABLE [db.]table
| MODIFY COLUMN name SET FULLTEXT [WITH <options>]
| RENAME name
| SET <option_name>=<option_value> [, ...]
| UNSET <option_name>[, ...]
]
```

Expand Down Expand Up @@ -97,6 +98,13 @@ ALTER TABLE monitor SET 'compaction.twcs.max_active_window_runs'='6';
ALTER TABLE monitor SET 'compaction.twcs.max_inactive_window_runs'='6';
```

#### 移除设置过的表参数

```sql
ALTER TABLE monitor UNSET 'ttl';
```


### 修改列全文索引选项

启用列的全文索引:
Expand All @@ -112,15 +120,15 @@ ALTER TABLE monitor MODIFY COLUMN load_15 SET FULLTEXT WITH (analyzer = 'Chinese

与 `CREATE TABLE` 一样,可以不带 `WITH` 选项,全部使用默认值。

关闭列的全文索引
#### 关闭列的全文索引

```sql
ALTER TABLE monitor MODIFY COLUMN load_15 UNSET FULLTEXT;
```

修改列的全文索引选项时,列的数据类型必须是字符串类型。

当列的全文索引关闭时,可以启用全文索引,并设置 `analyzer` 和 `case_sensitive` 选项;当列的全文索引选项已经启用时,可以关闭全文索引,但不能修改选项。
当列的全文索引未开启过时,可以启用全文索引,并设置 `analyzer` 和 `case_sensitive` 选项;当列的全文索引选项已经启用时,可以关闭全文索引,**但不能修改选项**

### 重命名表

Expand Down
Loading