diff --git a/sql-statements/sql-statement-create-index.md b/sql-statements/sql-statement-create-index.md index 19542c1c85be..77b3c0d2dc31 100644 --- a/sql-statements/sql-statement-create-index.md +++ b/sql-statements/sql-statement-create-index.md @@ -158,7 +158,7 @@ Query OK, 0 rows affected (0.31 sec) {{< copyable "sql" >}} ```sql -CREATE INDEX idx1 ON t1 (lower(col1)); +CREATE INDEX idx1 ON t1 ((lower(col1))); ``` 或者等价的语句: @@ -166,7 +166,7 @@ CREATE INDEX idx1 ON t1 (lower(col1)); {{< copyable "sql" >}} ```sql -ALTER TABLE t1 ADD INDEX idx1(lower(col1)); +ALTER TABLE t1 ADD INDEX idx1((lower(col1))); ``` 还可以在建表的同时指定表达式索引: @@ -174,9 +174,13 @@ ALTER TABLE t1 ADD INDEX idx1(lower(col1)); {{< 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)))); ``` +> **注意:** +> +> 表达式索引中的表达式需要用 `(` 和 `)` 包围起来,否则会报语法错误。 + 删除表达式索引与删除普通索引的方法一致: {{< copyable "sql" >}}