Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix example for expression index (#6499) #6574

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -110,25 +110,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