Skip to content

Commit

Permalink
fix example for expression index (pingcap#7127)
Browse files Browse the repository at this point in the history
  • Loading branch information
wjhuang2016 authored Sep 14, 2021
1 parent 70d05ba commit 49e4220
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions sql-statements/sql-statement-create-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,25 +158,29 @@ 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)));
```

或者等价的语句:

{{< copyable "sql" >}}

```sql
ALTER TABLE t1 ADD INDEX idx1(lower(col1));
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" >}}
Expand Down

0 comments on commit 49e4220

Please sign in to comment.