Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 2 additions & 5 deletions sql-statements/sql-statement-add-column.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ The `ALTER TABLE.. ADD COLUMN` statement adds a column to an existing table. Thi

![AlterTableSpec](/media/sqlgram/AlterTableSpec.png)

**ColumnKeywordOpt:**

![ColumnKeywordOpt](/media/sqlgram/ColumnKeywordOpt.png)

**ColumnDef:**

![ColumnDef](/media/sqlgram/ColumnDef.png)
Expand Down Expand Up @@ -73,9 +69,10 @@ mysql> SELECT * FROM t1;

## MySQL compatibility

* Adding multiple columns at the same time is currently not supported.
* Adding multiple columns at the same time in a statement is currently not supported.
* Adding a new column and setting it to the `PRIMARY KEY` is not supported.
* Adding a new column and setting it to `AUTO_INCREMENT` is not supported.
* There are limitations on adding generated columns, refer to: [generated column limitations](/generated-columns.md#limitations).

## See also

Expand Down
48 changes: 42 additions & 6 deletions sql-statements/sql-statement-add-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,53 @@ The `ALTER TABLE.. ADD INDEX` statement adds an index to an existing table. This

![AlterTableSpec](/media/sqlgram/AlterTableSpec.png)

**ColumnKeywordOpt:**
**Constraint:**

![ColumnKeywordOpt](/media/sqlgram/ColumnKeywordOpt.png)
![Constraint](/media/sqlgram/Constraint.png)

**ColumnDef:**
**ConstraintKeywordOpt:**

![ColumnDef](/media/sqlgram/ColumnDef.png)
![ConstraintKeywordOpt](/media/sqlgram/ConstraintKeywordOpt.png)

**ColumnPosition:**
**ConstraintElem:**

![ColumnPosition](/media/sqlgram/ColumnPosition.png)
![ConstraintElem](/media/sqlgram/ConstraintElem.png)

**IndexNameAndTypeOpt:**

![IndexNameAndTypeOpt](/media/sqlgram/IndexNameAndTypeOpt.png)

**IndexPartSpecificationList:**

![IndexPartSpecificationList](/media/sqlgram/IndexPartSpecificationList.png)

**IndexPartSpecification:**

![IndexPartSpecification](/media/sqlgram/IndexPartSpecification.png)

**IndexOptionList:**

![IndexOptionList](/media/sqlgram/IndexOptionList.png)

**IndexOption:**

![IndexOption](/media/sqlgram/IndexOption.png)

**KeyOrIndex:**

![KeyOrIndex](/media/sqlgram/KeyOrIndex.png)

**IndexKeyTypeOpt:**

![IndexKeyTypeOpt](/media/sqlgram/IndexKeyTypeOpt.png)

**IndexInvisible:**

![IndexInvisible](/media/sqlgram/IndexInvisible.png)

**IndexTypeName:**

![IndexTypeName](/media/sqlgram/IndexTypeName.png)

## Examples

Expand Down
10 changes: 10 additions & 0 deletions sql-statements/sql-statement-alter-database.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ aliases: ['/docs/stable/reference/sql/statements/alter-database/']

`ALTER DATABASE` is used to specify or modify the default character set and collation of the current database. `ALTER SCHEMA` has the same effect as `ALTER DATABASE`.

## 语法图

**AlterDatabaseStmt:**

![AlterDatabaseStmt](/media/sqlgram/AlterDatabaseStmt.png)

**DatabaseOption:**

![DatabaseOption](/media/sqlgram/DatabaseOption.png)

## Examples

```sql
Expand Down
6 changes: 6 additions & 0 deletions sql-statements/sql-statement-alter-instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ When an error occurs during reloading, by default, this error message is returne

## Syntax diagram

**AlterInstanceStmt:**

![AlterInstanceStmt](/media/sqlgram/AlterInstanceStmt.png)

**InstanceOption:**

![InstanceOption](/media/sqlgram/InstanceOption.png)

## Example

{{< copyable "sql" >}}
Expand Down
3 changes: 1 addition & 2 deletions sql-statements/sql-statement-alter-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ mysql> EXPLAIN SELECT * FROM t1 WHERE c1 = 3;

## MySQL compatibility

* All of the data types except spatial types are supported.
* `FULLTEXT`, `HASH` and `SPATIAL` indexes are not supported.
* All of the data types except spatial types are supported. For other unsupported cases, refer to: [compatibility of DDL statements with MySQL](/mysql-compatibility.md#ddl).

## See also

Expand Down
8 changes: 8 additions & 0 deletions sql-statements/sql-statement-alter-user.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ This statement changes an existing user inside the TiDB privilege system. In the

![UserSpec](/media/sqlgram/UserSpec.png)

**Username:**

![Username](/media/sqlgram/Username.png)

**AuthOption:**

![AuthOption](/media/sqlgram/AuthOption.png)

## Examples

```sql
Expand Down
4 changes: 0 additions & 4 deletions sql-statements/sql-statement-change-column.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ The `ALTER TABLE.. CHANGE COLUMN` statement changes a column on an existing tabl

![AlterTableSpec](/media/sqlgram/AlterTableSpec.png)

**ColumnKeywordOpt:**

![ColumnKeywordOpt](/media/sqlgram/ColumnKeywordOpt.png)

**ColumnName:**

![ColumnName](/media/sqlgram/ColumnName.png)
Expand Down
4 changes: 0 additions & 4 deletions sql-statements/sql-statement-create-database.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ This statement creates a new database in TiDB. The MySQL terminology for 'databa

![CreateDatabaseStmt](/media/sqlgram/CreateDatabaseStmt.png)

**DatabaseSym:**

![DatabaseSym](/media/sqlgram/DatabaseSym.png)

**IfNotExists:**

![IfNotExists](/media/sqlgram/IfNotExists.png)
Expand Down
5 changes: 1 addition & 4 deletions sql-statements/sql-statement-drop-column.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ This statement drops a column from a specified table. `DROP COLUMN` is online in

![AlterTableSpec](/media/sqlgram/AlterTableSpec.png)

**ColumnKeywordOpt:**

![ColumnKeywordOpt](/media/sqlgram/ColumnKeywordOpt.png)

**ColumnName:**

![ColumnName](/media/sqlgram/ColumnName.png)
Expand Down Expand Up @@ -82,6 +78,7 @@ mysql> SELECT * FROM t1;
## MySQL compatibility

* Dropping multiple columns in the same statement is not supported.
* Dropping primary key columns or index columns is not supported.

## See also

Expand Down
1 change: 1 addition & 0 deletions sql-statements/sql-statement-drop-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Query OK, 0 rows affected (0.23 sec)
## MySQL compatibility

* Dropping a table with `IF EXISTS` does not return a warning when attempting to drop a table that does not exist. [Issue #7867](https://github.com/pingcap/tidb/issues/7867)
* Currently `RESTRICT` and `CASCADE` are only supported syntactically.

## See also

Expand Down