From 56162cab09574d0513b8b428b9e9e5a8adb30226 Mon Sep 17 00:00:00 2001 From: shichun-0415 Date: Fri, 17 Sep 2021 16:56:54 +0800 Subject: [PATCH 1/2] fix example for expression index --- sql-statements/sql-statement-create-index.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sql-statements/sql-statement-create-index.md b/sql-statements/sql-statement-create-index.md index 512e158affd58..7b3e51b7445d7 100644 --- a/sql-statements/sql-statement-create-index.md +++ b/sql-statements/sql-statement-create-index.md @@ -111,7 +111,7 @@ For example, if you want to create an index based on `lower(col1)`, execute the {{< copyable "sql" >}} ```sql -CREATE INDEX idx1 ON t1 (lower(col1)); +CREATE INDEX idx1 ON t1 ((lower(col1))); ``` Or you can execute the following equivalent statement: @@ -119,7 +119,7 @@ Or you can execute the following equivalent statement: {{< copyable "sql" >}} ```sql -ALTER TABLE t1 ADD INDEX idx1(lower(col1)); +ALTER TABLE t1 ADD INDEX idx1((lower(col1))); ``` You can also specify the expression index when you create the table: @@ -127,9 +127,13 @@ You can also specify the expression index when you create the table: {{< copyable "sql" >}} ```sql -CREATE TABLE t1(col1 char(10), col2 char(10), key index(lower(col1))); +CREATE TABLE t1(col1 char(10), col2 char(10), key index((lower(col1)))); ``` +> **Note** +> +> The expression in the expression index must be surrounded by '(' and ')'. Otherwise, a syntax error will be reported. + You can drop an expression index in the same way as dropping an ordinary index: {{< copyable "sql" >}} From 75e083a268f64889e8d8dcb5778dcacb65f65721 Mon Sep 17 00:00:00 2001 From: TomShawn <41534398+TomShawn@users.noreply.github.com> Date: Wed, 29 Sep 2021 14:40:45 +0800 Subject: [PATCH 2/2] Update sql-statements/sql-statement-create-index.md --- sql-statements/sql-statement-create-index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-create-index.md b/sql-statements/sql-statement-create-index.md index 7b3e51b7445d7..d725c687ad8dc 100644 --- a/sql-statements/sql-statement-create-index.md +++ b/sql-statements/sql-statement-create-index.md @@ -132,7 +132,7 @@ CREATE TABLE t1(col1 char(10), col2 char(10), key index((lower(col1)))); > **Note** > -> The expression in the expression index must be surrounded by '(' and ')'. Otherwise, a syntax error will be reported. +> The expression in an expression index must be surrounded by '(' and ')'. Otherwise, a syntax error is reported. You can drop an expression index in the same way as dropping an ordinary index: