This is an automated email from the ASF dual-hosted git repository. kassiez pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris-website.git
The following commit(s) were added to refs/heads/master by this push: new 9e02a6f7015 [docs](sql-statement) Update CREATE INDEX (#2036) 9e02a6f7015 is described below commit 9e02a6f7015c41e0b9ce0a911bb86a0bb75f2a8c Author: KassieZ <139741991+kass...@users.noreply.github.com> AuthorDate: Thu Feb 13 12:30:29 2025 +0800 [docs](sql-statement) Update CREATE INDEX (#2036) ## Versions - [ ] dev - [ ] 3.0 - [ ] 2.1 - [ ] 2.0 ## Languages - [ ] Chinese - [ ] English ## Docs Checklist - [ ] Checked by AI - [ ] Test Cases Built --------- Co-authored-by: morrySnow <morrys...@126.com> --- .../table-and-view/index/CREATE-INDEX.md | 93 +++++++++++++++++---- .../docusaurus-plugin-content-docs/current.json | 4 +- .../table-and-view/index/CREATE-INDEX.md | 90 +++++++++++++++++---- .../version-2.1.json | 4 +- .../table-and-view/index/CREATE-INDEX.md | 84 ++++++++++++++++--- .../version-3.0.json | 4 +- .../table-and-view/index/CREATE-INDEX.md | 90 +++++++++++++++++---- .../table-and-view/index/CREATE-INDEX.md | 94 ++++++++++++++++++---- .../table-and-view/index/CREATE-INDEX.md | 93 +++++++++++++++++---- 9 files changed, 457 insertions(+), 99 deletions(-) diff --git a/docs/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md b/docs/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md index 43cf9bcddbe..f8c4a7b3eb5 100644 --- a/docs/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md +++ b/docs/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md @@ -27,29 +27,92 @@ under the License. ## Description -This statement is used to create an index -grammar: +Create a new index on a table. The table name and index name must be specified. Optionally, you can specify the index type, properties, and comments. + +## Syntax + ```sql -CREATE INDEX [IF NOT EXISTS] index_name ON table_name (column [, ...],) [USING INVERTED] [COMMENT 'balabala']; +CREATE INDEX [IF NOT EXISTS] <index_name> + ON <table_name> (<column_name> [, ...]) + [USING {INVERTED | NGRAM_BF}] + [PROPERTIES ("<key>" = "<value>"[ , ...])] + [COMMENT '<index_comment>'] ``` -Notice: -- INVERTED indexes are only created on a single column -## Example +## Required Parameters -1. Create a inverted index for siteid on table1 +**1. `<index_name>`** - ```sql - CREATE INDEX [IF NOT EXISTS] index_name ON table1 (siteid) USING INVERTED COMMENT 'balabala'; - ``` +> Specifies the identifier (i.e., name) of the index, which must be unique within its table. +> +> The identifier must start with a letter character (if Unicode name support is enabled, it can be any character from any language) and cannot contain spaces or special characters unless the entire identifier string is enclosed in backticks (e.g., `My Object`). +> +> The identifier cannot be a reserved keyword. +> +> For more details, refer to the requirements for identifiers and reserved keywords. +**2. `<table_name>`** -## Keywords +> Specifies the identifier (i.e., name) of the table, which must be unique within its database. +> +> The identifier must start with a letter character (if Unicode name support is enabled, it can be any character from any language) and cannot contain spaces or special characters unless the entire identifier string is enclosed in backticks (e.g., `My Object`). +> +> The identifier cannot be a reserved keyword. +> +> For more details, refer to the requirements for identifiers and reserved keywords. -```text -CREATE, INDEX -``` +**3. `<column_name> [, ...]`** + +> Specifies the columns on which the index is created (currently only one column is supported), and the column must be unique within its table. +> +> The identifier must start with a letter character (if Unicode name support is enabled, it can be any character from any language) and cannot contain spaces or special characters unless the entire identifier string is enclosed in backticks (e.g., `My Object`). +> +> The identifier cannot be a reserved keyword. +> +> For more details, refer to the requirements for identifiers and reserved keywords. + +## Optional Parameters + +**1. `USING {INVERTED | NGRAM_BF}`** + +> Specifies the index type. Currently, two types are supported: **INVERTED** (inverted index) and **NGRAM_BF** (ngram bloomfilter index). + +**2. `PROPERTIES ("<key>" = "<value>"[ , ...])`** + +> Specifies the parameters of the index using the general PROPERTIES format. For the parameters and semantics supported by each index, refer to the documentation for the specific index type. + +**3. `COMMENT '<index_comment>'`** + +> Specifies a comment for the index to facilitate maintenance. + +## Access Control Requirements + +The user executing this SQL command must have at least the following permissions: + +| Privilege | Object | Notes | +| ---------- | ------ | ---------------------------------------------------------- | +| ALTER_PRIV | Table | CREATE INDEX is considered an ALTER operation on the table | + +## Usage Notes + +- The **INVERTED** inverted index takes effect immediately for newly inserted data. For historical data, the index needs to be built using the BUILD INDEX operation. +- The **NGRAM_BF** NGram BloomFilter index will perform a schema change in the background on all data to complete the index construction after creation. The progress can be checked using SHOW ALTER TABLE COLUMN. + +## Examples + +- Create an inverted index `index1` on `table1` + + + + ```sql + CREATE INDEX index1 ON TABLE table1 USING INVERTED; + ``` + +- Create an NGram BloomFilter index `index2` on `table1` -## Best Practice + + ```sql + CREATE INDEX index2 ON TABLE table1 USING NGRAM_BF PROPERTIES("gram_size"="3", "bf_size"="1024"); + ``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current.json b/i18n/zh-CN/docusaurus-plugin-content-docs/current.json index d144cf7fd46..ae99b559cce 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current.json +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current.json @@ -271,9 +271,9 @@ "message": "集群管理", "description": "The label for category Managing Cluster in sidebar docs" }, - "sidebar.docs.category.Managing Disater Recovery": { + "sidebar.docs.category.Managing Disaster Recovery": { "message": "容灾管理", - "description": "The label for category Managing Disater Recovery in sidebar docs" + "description": "The label for category Managing Disaster Recovery in sidebar docs" }, "sidebar.docs.category.Managing Workload": { "message": "负载管理", diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md index 375e7bf140e..26c6912c5c8 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md @@ -27,33 +27,89 @@ under the License. - - ## 描述 -该语句用于创建索引 -语法: +为表创建新的索引,必须指定表名和索引名,可选指定索引类型、属性、注释。 + +## 语法 ```sql -CREATE INDEX [IF NOT EXISTS] index_name ON table_name (column [, ...],) [USING INVERTED] [COMMENT'balabala']; +CREATE INDEX [IF NOT EXISTS] <index_name> + ON <table_name> (<column_name> [, ...]) + [USING {INVERTED | NGRAM_BF}] + [PROPERTIES ("<key>" = "<value>"[ , ...])] + [COMMENT '<index_comment>'] ``` -注意: -- 倒排索引仅在单列上创建 -## 示例 +## 必选参数 -1. 在 table1 上为 siteid 创建倒排索引 +**1. `<index_name>`** - ```sql - CREATE INDEX [IF NOT EXISTS] index_name ON table1 (siteid) USING INVERTED COMMENT 'balabala'; - ``` +> 指定索引的标识符(即名称),在其所在的表(Table)中必须唯一。 +> +> 标识符必须以字母字符(如果开启 unicode 名字支持,则可以是任意语言文字的字符)开头,并且不能包含空格或特殊字符,除非整个标识符字符串用反引号括起来(例如`My Object`)。 +> +> 标识符不能使用保留关键字。 +> +> 有关更多详细信息,请参阅标识符要求和保留关键字。 +**2. `<table_name>`** -## 关键词 +> 指定表的标识符(即名称),在其所在的数据库(Database)中必须唯一。 +> +> 标识符必须以字母字符(如果开启 unicode 名字支持,则可以是任意语言文字的字符)开头,并且不能包含空格或特殊字符,除非整个标识符字符串用反引号括起来(例如`My Object`)。 +> +> 标识符不能使用保留关键字。 +> +> 有关更多详细信息,请参阅标识符要求和保留关键字。 -```text -CREATE, INDEX -``` +**3. `<column_name> [, ...]`** + +> 指定在哪些列上创建索引(目前仅支持一个),列在其所在的(Table)中必须唯一。 +> +> 标识符必须以字母字符(如果开启 unicode 名字支持,则可以是任意语言文字的字符)开头,并且不能包含空格或特殊字符,除非整个标识符字符串用反引号括起来(例如`My Object`)。 +> +> 标识符不能使用保留关键字。 +> +> 有关更多详细信息,请参阅标识符要求和保留关键字。 + +## 可选参数 + +**1. `USING {INVERTED | NGRAM_BF}`** + +> 指定索引类型,目前支持两种:**INVERTED** 倒排索引,**NGRAM_BF** ngram bloomfilter 索引。 + +**2. `PROPERTIES ("<key>" = "<value>"[ , ...])`** + +> 指定索引的参数,使用通用的 PROPERTIES 格式,每个索引支持的参数及语义,请参考具体类型的索引文档。 + +**3. `COMMENT '<index_comment>'`** + +> 指定索引的注释,便于维护。 + +## 权限控制 + +执行此 SQL 命令的用户必须至少具有以下权限: + +| 权限 | 对象 | 说明 | +| :---------------- | :------------- | :----------------------------- | +| ALTER_PRIV | 表 | CREATE INDEX 属于表 ALTER 操作 | + +## 注意事项 + +- **INVERTED** 倒排索引创建后对新写入的数据立即生效,历史数据的索引需要进行 BUILD INDEX 操作。 +- **NGRAM_BF** NGram BloomFilter 索引创建后会在后台对所用数据进行 schema change 以完成索引构建,进度可以通过 SHOW ALTER TABLE COLUMN 查看进度 + +## 示例 + +- 在 table1 上创建倒排索引 index1 + + ```sql + CREATE INDEX index1 ON TABLE table1 USING INVERTED; + ``` -### 最佳实践 +- 在 table1 上创建 NGram BloomFilter 索引 index2 + ```sql + CREATE INDEX index2 ON TABLE table1 USING NGRAM_BF PROPERTIES("gram_size"="3", "bf_size"="1024"); + ``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1.json b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1.json index 9dec52930c5..2d7a8f26444 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1.json +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1.json @@ -243,9 +243,9 @@ "message": "集群管理", "description": "The label for category Managing Cluster in sidebar docs" }, - "sidebar.docs.category.Managing Disater Recovery": { + "sidebar.docs.category.Managing Disaster Recovery": { "message": "容灾管理", - "description": "The label for category Managing Disater Recovery in sidebar docs" + "description": "The label for category Managing Disaster Recovery in sidebar docs" }, "sidebar.docs.category.Managing Resource": { "message": "资源管理", diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md index f8607e2904d..335b8fb55aa 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md @@ -30,29 +30,87 @@ under the License. ## 描述 -该语句用于创建索引 -语法: +为表创建新的索引,必须指定表名和索引名,可选指定索引类型、属性、注释。 + +## 语法 ```sql -CREATE INDEX [IF NOT EXISTS] index_name ON table_name (column [, ...],) [USING INVERTED] [COMMENT'balabala']; +CREATE INDEX [IF NOT EXISTS] <index_name> + ON <table_name> (<column_name> [, ...]) + [USING {INVERTED | NGRAM_BF}] + [PROPERTIES ("<key>" = "<value>"[ , ...])] + [COMMENT '<index_comment>'] ``` -注意: -- 倒排索引仅在单列上创建 -## 示例 +## 必选参数 + +**1. `<index_name>`** + +> 指定索引的标识符(即名称),在其所在的表(Table)中必须唯一。 +> +> 标识符必须以字母字符(如果开启 unicode 名字支持,则可以是任意语言文字的字符)开头,并且不能包含空格或特殊字符,除非整个标识符字符串用反引号括起来(例如`My Object`)。 +> +> 标识符不能使用保留关键字。 +> +> 有关更多详细信息,请参阅标识符要求和保留关键字。 + +**2. `<table_name>`** + +> 指定表的标识符(即名称),在其所在的数据库(Database)中必须唯一。 +> +> 标识符必须以字母字符(如果开启 unicode 名字支持,则可以是任意语言文字的字符)开头,并且不能包含空格或特殊字符,除非整个标识符字符串用反引号括起来(例如`My Object`)。 +> +> 标识符不能使用保留关键字。 +> +> 有关更多详细信息,请参阅标识符要求和保留关键字。 + +**3. `<column_name> [, ...]`** + +> 指定在哪些列上创建索引(目前仅支持一个),列在其所在的(Table)中必须唯一。 +> +> 标识符必须以字母字符(如果开启 unicode 名字支持,则可以是任意语言文字的字符)开头,并且不能包含空格或特殊字符,除非整个标识符字符串用反引号括起来(例如`My Object`)。 +> +> 标识符不能使用保留关键字。 +> +> 有关更多详细信息,请参阅标识符要求和保留关键字。 + +## 可选参数 -1. 在 table1 上为 siteid 创建倒排索引 +**1. `USING {INVERTED | NGRAM_BF}`** - ```sql - CREATE INDEX [IF NOT EXISTS] index_name ON table1 (siteid) USING INVERTED COMMENT 'balabala'; - ``` +> 指定索引类型,目前支持两种:**INVERTED** 倒排索引,**NGRAM_BF** ngram bloomfilter 索引。 +**2. `PROPERTIES ("<key>" = "<value>"[ , ...])`** -## 关键词 +> 指定索引的参数,使用通用的 PROPERTIES 格式,每个索引支持的参数及语义,请参考具体类型的索引文档。 +**3. `COMMENT '<index_comment>'`** + +> 指定索引的注释,便于维护。 + +## 权限控制 + +执行此 SQL 命令的用户必须至少具有以下权限: + +| 权限 | 对象 | 说明 | +| :---------------- | :------------- | :----------------------------- | +| ALTER_PRIV | 表 | CREATE INDEX 属于表 ALTER 操作 | + +## 注意事项 + +- **INVERTED** 倒排索引创建后对新写入的数据立即生效,历史数据的索引需要进行 BUILD INDEX 操作。 +- **NGRAM_BF** NGram BloomFilter 索引创建后会在后台对所用数据进行 schema change 以完成索引构建,进度可以通过 SHOW ALTER TABLE COLUMN 查看进度 + +## 示例 -CREATE, INDEX +- 在 table1 上创建倒排索引 index1 + ```sql + CREATE INDEX index1 ON TABLE table1 USING INVERTED; + ``` -## 最佳实践 +- 在 table1 上创建 NGram BloomFilter 索引 index2 + ```sql + CREATE INDEX index2 ON TABLE table1 USING NGRAM_BF PROPERTIES("gram_size"="3", "bf_size"="1024"); + ``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0.json b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0.json index dd9016433f3..67d736fe3ec 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0.json +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0.json @@ -643,9 +643,9 @@ "message": "历史版本", "description": "The label for category Release notes in sidebar docs" }, - "sidebar.docs.category.Managing Disater Recovery": { + "sidebar.docs.category.Managing Disaster Recovery": { "message": "容灾管理", - "description": "The label for category Managing Disater Recovery in sidebar docs" + "description": "The label for category Managing Disaster Recovery in sidebar docs" }, "sidebar.docs.category.Managing Workload": { "message": "负载管理", diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md index 375e7bf140e..26c6912c5c8 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md @@ -27,33 +27,89 @@ under the License. - - ## 描述 -该语句用于创建索引 -语法: +为表创建新的索引,必须指定表名和索引名,可选指定索引类型、属性、注释。 + +## 语法 ```sql -CREATE INDEX [IF NOT EXISTS] index_name ON table_name (column [, ...],) [USING INVERTED] [COMMENT'balabala']; +CREATE INDEX [IF NOT EXISTS] <index_name> + ON <table_name> (<column_name> [, ...]) + [USING {INVERTED | NGRAM_BF}] + [PROPERTIES ("<key>" = "<value>"[ , ...])] + [COMMENT '<index_comment>'] ``` -注意: -- 倒排索引仅在单列上创建 -## 示例 +## 必选参数 -1. 在 table1 上为 siteid 创建倒排索引 +**1. `<index_name>`** - ```sql - CREATE INDEX [IF NOT EXISTS] index_name ON table1 (siteid) USING INVERTED COMMENT 'balabala'; - ``` +> 指定索引的标识符(即名称),在其所在的表(Table)中必须唯一。 +> +> 标识符必须以字母字符(如果开启 unicode 名字支持,则可以是任意语言文字的字符)开头,并且不能包含空格或特殊字符,除非整个标识符字符串用反引号括起来(例如`My Object`)。 +> +> 标识符不能使用保留关键字。 +> +> 有关更多详细信息,请参阅标识符要求和保留关键字。 +**2. `<table_name>`** -## 关键词 +> 指定表的标识符(即名称),在其所在的数据库(Database)中必须唯一。 +> +> 标识符必须以字母字符(如果开启 unicode 名字支持,则可以是任意语言文字的字符)开头,并且不能包含空格或特殊字符,除非整个标识符字符串用反引号括起来(例如`My Object`)。 +> +> 标识符不能使用保留关键字。 +> +> 有关更多详细信息,请参阅标识符要求和保留关键字。 -```text -CREATE, INDEX -``` +**3. `<column_name> [, ...]`** + +> 指定在哪些列上创建索引(目前仅支持一个),列在其所在的(Table)中必须唯一。 +> +> 标识符必须以字母字符(如果开启 unicode 名字支持,则可以是任意语言文字的字符)开头,并且不能包含空格或特殊字符,除非整个标识符字符串用反引号括起来(例如`My Object`)。 +> +> 标识符不能使用保留关键字。 +> +> 有关更多详细信息,请参阅标识符要求和保留关键字。 + +## 可选参数 + +**1. `USING {INVERTED | NGRAM_BF}`** + +> 指定索引类型,目前支持两种:**INVERTED** 倒排索引,**NGRAM_BF** ngram bloomfilter 索引。 + +**2. `PROPERTIES ("<key>" = "<value>"[ , ...])`** + +> 指定索引的参数,使用通用的 PROPERTIES 格式,每个索引支持的参数及语义,请参考具体类型的索引文档。 + +**3. `COMMENT '<index_comment>'`** + +> 指定索引的注释,便于维护。 + +## 权限控制 + +执行此 SQL 命令的用户必须至少具有以下权限: + +| 权限 | 对象 | 说明 | +| :---------------- | :------------- | :----------------------------- | +| ALTER_PRIV | 表 | CREATE INDEX 属于表 ALTER 操作 | + +## 注意事项 + +- **INVERTED** 倒排索引创建后对新写入的数据立即生效,历史数据的索引需要进行 BUILD INDEX 操作。 +- **NGRAM_BF** NGram BloomFilter 索引创建后会在后台对所用数据进行 schema change 以完成索引构建,进度可以通过 SHOW ALTER TABLE COLUMN 查看进度 + +## 示例 + +- 在 table1 上创建倒排索引 index1 + + ```sql + CREATE INDEX index1 ON TABLE table1 USING INVERTED; + ``` -### 最佳实践 +- 在 table1 上创建 NGram BloomFilter 索引 index2 + ```sql + CREATE INDEX index2 ON TABLE table1 USING NGRAM_BF PROPERTIES("gram_size"="3", "bf_size"="1024"); + ``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md b/versioned_docs/version-2.1/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md index cfe5b4b3703..a74c7a65bf4 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md +++ b/versioned_docs/version-2.1/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md @@ -24,32 +24,94 @@ specific language governing permissions and limitations under the License. --> - ## Description -This statement is used to create an index -grammar: +Create a new index on a table. The table name and index name must be specified. Optionally, you can specify the index type, properties, and comments. + +## Syntax + ```sql -CREATE INDEX [IF NOT EXISTS] index_name ON table_name (column [, ...],) [USING INVERTED] [COMMENT 'balabala']; +CREATE INDEX [IF NOT EXISTS] <index_name> + ON <table_name> (<column_name> [, ...]) + [USING {INVERTED | NGRAM_BF}] + [PROPERTIES ("<key>" = "<value>"[ , ...])] + [COMMENT '<index_comment>'] ``` -Notice: -- INVERTED indexes are only created on a single column -## Examples +## Required Parameters -1. Create a inverted index for siteid on table1 +**1. `<index_name>`** - ```sql - CREATE INDEX [IF NOT EXISTS] index_name ON table1 (siteid) USING INVERTED COMMENT 'balabala'; - ``` +> Specifies the identifier (i.e., name) of the index, which must be unique within its table. +> +> The identifier must start with a letter character (if Unicode name support is enabled, it can be any character from any language) and cannot contain spaces or special characters unless the entire identifier string is enclosed in backticks (e.g., `My Object`). +> +> The identifier cannot be a reserved keyword. +> +> For more details, refer to the requirements for identifiers and reserved keywords. +**2. `<table_name>`** -## Keywords +> Specifies the identifier (i.e., name) of the table, which must be unique within its database. +> +> The identifier must start with a letter character (if Unicode name support is enabled, it can be any character from any language) and cannot contain spaces or special characters unless the entire identifier string is enclosed in backticks (e.g., `My Object`). +> +> The identifier cannot be a reserved keyword. +> +> For more details, refer to the requirements for identifiers and reserved keywords. -```text -CREATE, INDEX -``` +**3. `<column_name> [, ...]`** + +> Specifies the columns on which the index is created (currently only one column is supported), and the column must be unique within its table. +> +> The identifier must start with a letter character (if Unicode name support is enabled, it can be any character from any language) and cannot contain spaces or special characters unless the entire identifier string is enclosed in backticks (e.g., `My Object`). +> +> The identifier cannot be a reserved keyword. +> +> For more details, refer to the requirements for identifiers and reserved keywords. + +## Optional Parameters + +**1. `USING {INVERTED | NGRAM_BF}`** + +> Specifies the index type. Currently, two types are supported: **INVERTED** (inverted index) and **NGRAM_BF** (ngram bloomfilter index). + +**2. `PROPERTIES ("<key>" = "<value>"[ , ...])`** + +> Specifies the parameters of the index using the general PROPERTIES format. For the parameters and semantics supported by each index, refer to the documentation for the specific index type. + +**3. `COMMENT '<index_comment>'`** + +> Specifies a comment for the index to facilitate maintenance. + +## Access Control Requirements + +The user executing this SQL command must have at least the following permissions: + +| Privilege | Object | Notes | +| ---------- | ------ | ---------------------------------------------------------- | +| ALTER_PRIV | Table | CREATE INDEX is considered an ALTER operation on the table | + +## Usage Notes + +- The **INVERTED** inverted index takes effect immediately for newly inserted data. For historical data, the index needs to be built using the BUILD INDEX operation. +- The **NGRAM_BF** NGram BloomFilter index will perform a schema change in the background on all data to complete the index construction after creation. The progress can be checked using SHOW ALTER TABLE COLUMN. + +## Examples + +- Create an inverted index `index1` on `table1` + + + + ```sql + CREATE INDEX index1 ON TABLE table1 USING INVERTED; + ``` + +- Create an NGram BloomFilter index `index2` on `table1` -## Best Practice + + ```sql + CREATE INDEX index2 ON TABLE table1 USING NGRAM_BF PROPERTIES("gram_size"="3", "bf_size"="1024"); + ``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md b/versioned_docs/version-3.0/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md index 43cf9bcddbe..f8c4a7b3eb5 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md +++ b/versioned_docs/version-3.0/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md @@ -27,29 +27,92 @@ under the License. ## Description -This statement is used to create an index -grammar: +Create a new index on a table. The table name and index name must be specified. Optionally, you can specify the index type, properties, and comments. + +## Syntax + ```sql -CREATE INDEX [IF NOT EXISTS] index_name ON table_name (column [, ...],) [USING INVERTED] [COMMENT 'balabala']; +CREATE INDEX [IF NOT EXISTS] <index_name> + ON <table_name> (<column_name> [, ...]) + [USING {INVERTED | NGRAM_BF}] + [PROPERTIES ("<key>" = "<value>"[ , ...])] + [COMMENT '<index_comment>'] ``` -Notice: -- INVERTED indexes are only created on a single column -## Example +## Required Parameters -1. Create a inverted index for siteid on table1 +**1. `<index_name>`** - ```sql - CREATE INDEX [IF NOT EXISTS] index_name ON table1 (siteid) USING INVERTED COMMENT 'balabala'; - ``` +> Specifies the identifier (i.e., name) of the index, which must be unique within its table. +> +> The identifier must start with a letter character (if Unicode name support is enabled, it can be any character from any language) and cannot contain spaces or special characters unless the entire identifier string is enclosed in backticks (e.g., `My Object`). +> +> The identifier cannot be a reserved keyword. +> +> For more details, refer to the requirements for identifiers and reserved keywords. +**2. `<table_name>`** -## Keywords +> Specifies the identifier (i.e., name) of the table, which must be unique within its database. +> +> The identifier must start with a letter character (if Unicode name support is enabled, it can be any character from any language) and cannot contain spaces or special characters unless the entire identifier string is enclosed in backticks (e.g., `My Object`). +> +> The identifier cannot be a reserved keyword. +> +> For more details, refer to the requirements for identifiers and reserved keywords. -```text -CREATE, INDEX -``` +**3. `<column_name> [, ...]`** + +> Specifies the columns on which the index is created (currently only one column is supported), and the column must be unique within its table. +> +> The identifier must start with a letter character (if Unicode name support is enabled, it can be any character from any language) and cannot contain spaces or special characters unless the entire identifier string is enclosed in backticks (e.g., `My Object`). +> +> The identifier cannot be a reserved keyword. +> +> For more details, refer to the requirements for identifiers and reserved keywords. + +## Optional Parameters + +**1. `USING {INVERTED | NGRAM_BF}`** + +> Specifies the index type. Currently, two types are supported: **INVERTED** (inverted index) and **NGRAM_BF** (ngram bloomfilter index). + +**2. `PROPERTIES ("<key>" = "<value>"[ , ...])`** + +> Specifies the parameters of the index using the general PROPERTIES format. For the parameters and semantics supported by each index, refer to the documentation for the specific index type. + +**3. `COMMENT '<index_comment>'`** + +> Specifies a comment for the index to facilitate maintenance. + +## Access Control Requirements + +The user executing this SQL command must have at least the following permissions: + +| Privilege | Object | Notes | +| ---------- | ------ | ---------------------------------------------------------- | +| ALTER_PRIV | Table | CREATE INDEX is considered an ALTER operation on the table | + +## Usage Notes + +- The **INVERTED** inverted index takes effect immediately for newly inserted data. For historical data, the index needs to be built using the BUILD INDEX operation. +- The **NGRAM_BF** NGram BloomFilter index will perform a schema change in the background on all data to complete the index construction after creation. The progress can be checked using SHOW ALTER TABLE COLUMN. + +## Examples + +- Create an inverted index `index1` on `table1` + + + + ```sql + CREATE INDEX index1 ON TABLE table1 USING INVERTED; + ``` + +- Create an NGram BloomFilter index `index2` on `table1` -## Best Practice + + ```sql + CREATE INDEX index2 ON TABLE table1 USING NGRAM_BF PROPERTIES("gram_size"="3", "bf_size"="1024"); + ``` \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org