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

update several 'CREATE' related statement: #3293

Merged
merged 5 commits into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
Binary file added media/sqlgram/ColumnOptionList.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/sqlgram/CreateTableLikeStmt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/sqlgram/SequenceOptionList.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 38 additions & 10 deletions sql-statements/sql-statement-create-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,62 @@ aliases: ['/docs-cn/dev/reference/sql/statements/create-index/']

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

**CreateIndexStmtUnique:**
**IndexKeyTypeOpt:**

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

**Identifier:**
**IfNotExists:**

![Identifier](/media/sqlgram/Identifier.png)
![IfNotExists](/media/sqlgram/IfNotExists.png)

**IndexTypeOpt:**

![IndexTypeOpt](/media/sqlgram/IndexTypeOpt.png)
Comment on lines +22 to 28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These diagrams are wrong. They have no empty branches.


**TableName:**
**IndexPartSpecificationList:**

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

**IndexColNameList:**

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

**IndexOptionList:**

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

**IndexLockAndAlgorithmOpt:**

![IndexLockAndAlgorithmOpt](/media/sqlgram/IndexLockAndAlgorithmOpt.png)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto


**IndexType:**

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

**IndexPartSpecification:**

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

**IndexOption:**

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

**IndexTypeName:**

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

**ColumnName:**

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

**OptFieldLen:**

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

**IndexNameList:**

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

**KeyOrIndex:**

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

## 示例

{{< copyable "sql" >}}
Expand Down
12 changes: 4 additions & 8 deletions sql-statements/sql-statement-create-sequence.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ aliases: ['/docs-cn/dev/reference/sql/statements/create-sequence/']

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

**OptTemporary:**

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

**IfNotExists:**

![IfNotExists](/media/sqlgram/IfNotExists.png)
Expand All @@ -31,13 +27,13 @@ aliases: ['/docs-cn/dev/reference/sql/statements/create-sequence/']

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

**SequenceOption:**
**SequenceOptionList:**

![SequenceOption](/media/sqlgram/SequenceOption.png)
![SequenceOptionList](/media/sqlgram/SequenceOptionList.png)

**CreateTableOptionListOpt:**
**SequenceOption:**

![CreateTableOptionListOpt](/media/sqlgram/CreateTableOptionListOpt.png)
![SequenceOption](/media/sqlgram/SequenceOption.png)

## 语法说明

Expand Down
12 changes: 6 additions & 6 deletions sql-statements/sql-statement-create-table-like.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,14 @@ aliases: ['/docs-cn/dev/reference/sql/statements/create-table-like/']

## 语法图

**CreateTableStmt:**
**CreateTableLikeStmt:**

![CreateTableStmt](/media/sqlgram/CreateTableStmt.png)
![CreateTableLikeStmt](/media/sqlgram/CreateTableLikeStmt.png)

**LikeTableWithOrWithoutParen:**

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

**TableName:**

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

## 示例

{{< copyable "sql" >}}
Expand Down Expand Up @@ -85,6 +81,10 @@ SELECT * FROM t2;
Empty set (0.00 sec)
```

## Region 的预切分

如果被复制的表定义了 `PRE_SPLIT_REGIONS` 属性,则通过 `CREATE TABLE LIKE` 语句复制的表,会继承该属性并在建表时预切分 Region。关于 `PRE_SPLIT_REGIONS` 属性的说明,参见 [`CREATE TABLE` 语句](/sql-statements/sql-statement-create-table.md)。

## MySQL 兼容性

`CREATE TABLE LIKE` 语句与 MySQL 完全兼容。如有任何兼容性差异,请在 GitHub 上提交 [issue](/report-issue.md)。
Expand Down
51 changes: 36 additions & 15 deletions sql-statements/sql-statement-create-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,49 @@ aliases: ['/docs-cn/dev/reference/sql/statements/create-table/']

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

**TableElement:**
**TableElementList:**

![TableElement](/media/sqlgram/TableElement.png)
![TableElementList](/media/sqlgram/TableElementList.png)

**PartitionOpt:**
**TableElement:**

![PartitionOpt](/media/sqlgram/PartitionOpt.png)
![TableElement](/media/sqlgram/TableElement.png)

**ColumnDef:**

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

**ColumnName:**
**ColumnOptionListOpt:**

![ColumnName](/media/sqlgram/ColumnName.png)
![ColumnOptionListOpt](/media/sqlgram/ColumnOptionListOpt.png)

**Type:**
**ColumnOptionList:**

![Type](/media/sqlgram/Type.png)
![ColumnOptionList](/media/sqlgram/ColumnOptionList.png)

**ColumnOptionListOpt:**
**ColumnOption:**

![ColumnOptionListOpt](/media/sqlgram/ColumnOptionListOpt.png)
![ColumnOption](/media/sqlgram/ColumnOption.png)

**CreateTableOptionListOpt:**

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

**PartitionOpt:**

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

**DuplicateOpt:**

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

**TableOptionList:**

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

**TableOptionListOpt:**
**TableOption:**

![TableOptionListOpt](/media/sqlgram/TableOptionListOpt.png)
![TableOption](/media/sqlgram/TableOption.png)

## 语法说明

Expand Down Expand Up @@ -220,11 +236,15 @@ table_option:
|`AUTO_INCREMENT`|自增字段初始值 |`AUTO_INCREMENT` = 5|
|`SHARD_ROW_ID_BITS`|用来设置隐式 _tidb_rowid 的分片数量的 bit 位数 |`SHARD_ROW_ID_BITS` = 4|
|`PRE_SPLIT_REGIONS`|用来在建表时预先均匀切分 `2^(PRE_SPLIT_REGIONS)` 个 Region |`PRE_SPLIT_REGIONS` = 4|
|`AUTO_ID_CACHE`|用来指定 Auto ID 在 TiDB 实例中 Cache 的大小,默认情况下 TiDB 会根据 Auto ID 分配速度自动调整 |`AUTO_ID_CACHE` = 200|
|`AUTO_RANDOM_BASE`|用来指定 AutoRandom 自增部分的初始值,该参数可以被认为属于内部接口的一部分,对于用户而言请忽略 |`AUTO_RANDOM_BASE` = 0|
|`CHARACTER SET` |指定该表所使用的字符集 | `CHARACTER SET` = 'utf8mb4'|
|`COLLATE` |指定该表所使用的字符集排序规则 | `COLLATE` = 'utf8mb4_bin'|
|`COMMENT` |注释信息 | `COMMENT` = 'comment info'|

`split-table` 配置项默认情况下会开启,在此配置项开启时,建表操作会为每个表建立单独的 Region。
> **注意:**
>
> 在 TiDB 配置文件中,`split-table` 默认开启。当该配置项开启时,建表操作会为每个表建立单独的 Region,详情参见 [TiDB 配置文件描述](/tidb-configuration-file.md) 。

## 示例

Expand Down Expand Up @@ -290,14 +310,15 @@ SELECT * FROM t1;

## MySQL 兼容性

* TiDB 不支持 `CREATE TEMPORARY TABLE` 语法。
* TiDB 不支持临时表,对于 `CREATE TEMPORARY TABLE` 语法,会忽略 `TEMPORARY` 关键字
* 支持除空间类型以外的所有数据类型。
* 不支持 `FULLTEXT`,`HASH` 和 `SPATIAL` 索引。
* `KEY_BLOCK_SIZE` 和 `ENGINE` 属性可被解析,但会被忽略。
* `index_col_name` 属性支持 length 选项,最大长度限制为 3072 字节。此长度限制不会更改,具体取决于存储引擎和建表时使用的字符集
* `index_col_name` 属性支持 length 选项,最大长度默认限制为 3072 字节。此长度限制可以通过配置项 `max-index-length` 更改,具体请参阅 [TiDB 配置文件描述](/tidb-configuration-file.md#max-index-length)
* `index_col_name` 属性支持 `ASC` 和 `DESC` 的索引排序选项。
* `COMMENT` 属性最多支持 1024 个字符,不支持 `WITH PARSER` 选项。
* TiDB 在单个表中最多支持 512 列。InnoDB 中相应的数量限制为 1017,MySQL 中的硬限制为 4096。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

关于创建分区表的兼容性问题要放这里面吗?获取可以有连接到的地址吗?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

恩可以加一下

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bb7133 请更新一下~

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, PTAL

* 当前仅支持 Range、Hash 和 Range Columns(单列)类型的分区表,详情参阅[分区表](/partitioned-table.md)。

## 另请参阅

Expand Down