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

align 4 PR from docs-cn (#10808) #11176

Merged
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
1 change: 1 addition & 0 deletions TOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@
- [`SHOW COLLATION`](/sql-statements/sql-statement-show-collation.md)
- [`SHOW [FULL] COLUMNS FROM`](/sql-statements/sql-statement-show-columns-from.md)
- [`SHOW CONFIG`](/sql-statements/sql-statement-show-config.md)
- [`SHOW CREATE DATABASE`](/sql-statements/sql-statement-show-create-database.md)
- [`SHOW CREATE PLACEMENT POLICY`](/sql-statements/sql-statement-show-create-placement-policy.md)
- [`SHOW CREATE SEQUENCE`](/sql-statements/sql-statement-show-create-sequence.md)
- [`SHOW CREATE TABLE`](/sql-statements/sql-statement-show-create-table.md)
Expand Down
2 changes: 0 additions & 2 deletions functions-and-operators/miscellaneous-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,5 @@ TiDB supports most of the [miscellaneous functions](https://dev.mysql.com/doc/re

| Name | Description |
|:------------|:-----------------------------------------------------------------------------------------------|
| [`GET_LOCK()`](https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_get-lock) | Get a named lock [TiDB #10929](https://github.com/pingcap/tidb/issues/14994) |
| [`RELEASE_LOCK()`](https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_release-lock) | Releases the named lock [TiDB #10929](https://github.com/pingcap/tidb/issues/14994) |
| [`UUID_SHORT()`](https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_uuid-short) | Provides a UUID that is unique given certain assumptions not present in TiDB [TiDB #4620](https://github.com/pingcap/tidb/issues/4620) |
| [`MASTER_WAIT_POS()`](https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_master-pos-wait) | Relates to MySQL replication |
8 changes: 6 additions & 2 deletions information-schema/information-schema-tidb-indexes.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ DESC tidb_indexes;
| INDEX_COMMENT | varchar(2048) | YES | | NULL | |
| Expression | varchar(64) | YES | | NULL | |
| INDEX_ID | bigint(21) | YES | | NULL | |
| IS_VISIBLE | varchar(64) | YES | | NULL | |
| CLUSTERED | varchar(64) | YES | | NULL | |
+---------------+---------------+------+------+---------+-------+
10 rows in set (0.00 sec)
12 rows in set (0.00 sec)
```

`INDEX_ID` is the unique ID that TiDB allocates for each index. It can be used to do a join operation with `INDEX_ID` obtained from another table or API.
Expand Down Expand Up @@ -59,4 +61,6 @@ Fields in the `TIDB_INDEXES` table are described as follows:
* `COLUMN_NAME`: The name of the column where the index is located.
* `SUB_PART`: The prefix length of the index. If the the column is partly indexed, the `SUB_PART` value is the count of the indexed characters; otherwise, the value is `NULL`.
* `INDEX_COMMENT`: The comment of the index, which is made when the index is created.
* `INDEX_ID`: The index ID.
* `INDEX_ID`: The index ID.
* `IS_VISIBLE`: Whether the index is visible.
* `CLUSTERED`: Whether it is a [clustered index](/clustered-indexes.md).
5 changes: 5 additions & 0 deletions sql-statements/sql-statement-alter-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ AlterTableSpec ::=
| 'SECONDARY_UNLOAD'
| ( 'AUTO_INCREMENT' | 'AUTO_ID_CACHE' | 'AUTO_RANDOM_BASE' | 'SHARD_ROW_ID_BITS' ) EqOpt LengthNum
| ( 'CACHE' | 'NOCACHE' )
| PlacementPolicyOption

PlacementPolicyOption ::=
"PLACEMENT" "POLICY" EqOpt PolicyName
| "PLACEMENT" "POLICY" (EqOpt | "SET") "DEFAULT"
```

## Examples
Expand Down
11 changes: 11 additions & 0 deletions sql-statements/sql-statement-create-database.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ DBName ::=

DatabaseOptionListOpt ::=
DatabaseOptionList?

DatabaseOptionList ::=
DatabaseOption ( ','? DatabaseOption )*

DatabaseOption ::=
DefaultKwdOpt ( CharsetKw '='? CharsetName | 'COLLATE' '='? CollationName | 'ENCRYPTION' '='? EncryptionOpt )
| DefaultKwdOpt PlacementPolicyOption

PlacementPolicyOption ::=
"PLACEMENT" "POLICY" EqOpt PolicyName
| "PLACEMENT" "POLICY" (EqOpt | "SET") "DEFAULT"
```

## Syntax
Expand Down
5 changes: 5 additions & 0 deletions sql-statements/sql-statement-create-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,14 @@ TableOption ::=
| 'SECONDARY_ENGINE' EqOpt ( 'NULL' | StringName )
| 'UNION' EqOpt '(' TableNameListOpt ')'
| 'ENCRYPTION' EqOpt EncryptionOpt
| PlacementPolicyOption

OnCommitOpt ::=
('ON' 'COMMIT' 'DELETE' 'ROWS')?

PlacementPolicyOption ::=
"PLACEMENT" "POLICY" EqOpt PolicyName
| "PLACEMENT" "POLICY" (EqOpt | "SET") "DEFAULT"
```

The following *table_options* are supported. Other options such as `AVG_ROW_LENGTH`, `CHECKSUM`, `COMPRESSION`, `CONNECTION`, `DELAY_KEY_WRITE`, `ENGINE`, `KEY_BLOCK_SIZE`, `MAX_ROWS`, `MIN_ROWS`, `ROW_FORMAT` and `STATS_PERSISTENT` are parsed but ignored.
Expand Down
64 changes: 64 additions & 0 deletions sql-statements/sql-statement-show-create-database.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
title: SHOW CREATE DATABASE
summary: An overview of the use of SHOW CREATE DATABASE in the TiDB database.
---

# SHOW CREATE DATABASE

`SHOW CREATE DATABASE` is used to show the exact SQL statement for re-creating an existing database. `SHOW CREATE SCHEMA` is a synonym for it.

## Synopsis

**ShowCreateDatabaseStmt:**

```ebnf+diagram
ShowCreateDatabaseStmt ::=
"SHOW" "CREATE" "DATABASE" | "SCHEMA" ("IF" "NOT" "EXISTS")? DBName
```

## Examples

```sql
CREATE DATABASE test;
```

```sql
Query OK, 0 rows affected (0.12 sec)
```

```sql
SHOW CREATE DATABASE test;
```

```sql
+----------+------------------------------------------------------------------+
| Database | Create Database |
+----------+------------------------------------------------------------------+
| test | CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET utf8mb4 */ |
+----------+------------------------------------------------------------------+
1 row in set (0.00 sec)
```

```sql
SHOW CREATE SCHEMA IF NOT EXISTS test;
```

```sql
+----------+-------------------------------------------------------------------------------------------+
| Database | Create Database |
+----------+-------------------------------------------------------------------------------------------+
| test | CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET utf8mb4 */ |
+----------+-------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
```

## MySQL compatibility

`SHOW CREATE DATABASE` is expected to be fully compatible with MySQL. If you find any compatibility differences, submit a GitHub [issue](https://github.com/pingcap/tidb/issues/new/choose).

## See also

* [CREATE TABLE](/sql-statements/sql-statement-create-table.md)
* [DROP TABLE](/sql-statements/sql-statement-drop-table.md)
* [SHOW TABLES](/sql-statements/sql-statement-show-tables.md)
* [SHOW COLUMNS FROM](/sql-statements/sql-statement-show-columns-from.md)