Skip to content

Commit

Permalink
fix example for expression index (#6499)
Browse files Browse the repository at this point in the history
  • Loading branch information
shichun-0415 authored Sep 29, 2021
1 parent ca169c4 commit f88e91d
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 @@ -111,25 +111,29 @@ 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:

{{< 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:

{{< 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 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:

{{< copyable "sql" >}}
Expand Down

0 comments on commit f88e91d

Please sign in to comment.