Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
22 changes: 22 additions & 0 deletions docs/reference/sql/alter.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ALTER TABLE [db.]table
[ADD COLUMN name type [options]
| DROP COLUMN name
| MODIFY COLUMN name type
| MODIFY COLUMN name SET FULLTEXT [WITH <options>]
| RENAME name
| SET <option_name>=<option_value> [, ...]
]
Expand Down Expand Up @@ -77,6 +78,27 @@ Currently following options are supported:
ALTER TABLE monitor SET 'ttl'='1d';
```

### Modify column fulltext index options

Modify the fulltext index options of a column
Comment thread
nicecui marked this conversation as resolved.
Outdated

```sql
ALTER TABLE monitor MODIFY COLUMN load_15 SET FULLTEXT WITH (enable = 'true', analyzer = 'Chinese', case_sensitive = 'false');
```

You can specify the following options using `FULLTEXT WITH`:

- `enable`: Determines whether the full-text index is enabled. Supported values are `true` and `false`. Default is `true`.
- `analyzer`: Sets the language analyzer for the full-text index. Supported values are `English` and `Chinese`. Default is `English`.
- `case_sensitive`: Determines whether the full-text index is case-sensitive. Supported values are `true` and `false`. Default is `false`.

If `WITH` is not specified, `FULLTEXT` will use the default values.
Comment thread
CookiePieWw marked this conversation as resolved.
Outdated

Currently, the fulltext index can be altered when:

1. The column is of a string type.
2. Either the column has no fulltext index and the alter command is to enable it, or the column has a fulltext index and the alter command is to disable it.
Comment thread
nicecui marked this conversation as resolved.
Outdated

### Rename table

Renames the table:
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/sql/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ You can specify the following options using `FULLTEXT WITH`:
If `WITH` is not specified, `FULLTEXT` will use the following default values:

- `analyzer`: default is `English`
- `case_sensitive`: default is `true`
- `case_sensitive`: default is `false`
Comment thread
zhongzc marked this conversation as resolved.

For example, to create a table with a full-text index on the `log` column, configuring the analyzer to `Chinese` and setting `case_sensitive` to `false`:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ALTER TABLE [db.]table
[ADD COLUMN name type [options]
| DROP COLUMN name
| MODIFY COLUMN name type
| MODIFY COLUMN name SET FULLTEXT [WITH <options>]
| RENAME name
| SET <option_name>=<option_value> [, ...]
]
Expand Down Expand Up @@ -77,6 +78,27 @@ ALTER TABLE monitor MODIFY COLUMN load_15 STRING;
ALTER TABLE monitor SET 'ttl'='1d';
```

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

修改列的全文索引选项
Comment thread
nicecui marked this conversation as resolved.
Outdated

```sql
ALTER TABLE monitor MODIFY COLUMN load_15 SET FULLTEXT WITH (enable = 'true', analyzer = 'Chinese', case_sensitive = 'false');
```

使用 `FULLTEXT WITH` 可以指定以下选项:

- `enable`:设置全文索引是否启用,支持 `true` 和 `false`。默认为 `false`。
- `analyzer`:设置全文索引的分析器语言,支持 `English` 和 `Chinese`。默认为 `English`。
- `case_sensitive`:设置全文索引是否区分大小写,支持 `true` 和 `false`。默认为 `false`。

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

目前,修改列的全文索引选项需要:

1. 列必须是字符串类型。
2. 列已经启用了全文索引时,只能关闭全文索引,不能修改分词器和大小写敏感性;未启用全文索引时,可以启用全文索引并设置分词器和大小写敏感性。

### 重命名表

```sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ Query OK, 0 rows affected (0.01 sec)
如果不带 `WITH` 选项,`FULLTEXT` 将使用默认值:

- `analyzer`:默认 `English`
- `case_sensitive`:默认 `true`
- `case_sensitive`:默认 `false`

例如,要创建一个带有全文索引的表,配置 `log` 列为全文索引,并指定分析器为 `Chinese` 且不区分大小写:

Expand Down