From ca3bd64c1e450c83211481e2c13c895ee9c3208b Mon Sep 17 00:00:00 2001 From: tangenta Date: Fri, 22 May 2020 13:14:23 +0800 Subject: [PATCH 1/6] update keywords-and-reserved-words.md --- keywords-and-reserved-words.md | 303 +++++++++++++++++++++++++++------ 1 file changed, 249 insertions(+), 54 deletions(-) diff --git a/keywords-and-reserved-words.md b/keywords-and-reserved-words.md index c01788f0cbbe..3826b3463e41 100644 --- a/keywords-and-reserved-words.md +++ b/keywords-and-reserved-words.md @@ -1,12 +1,17 @@ --- title: 关键字和保留字 category: reference +summary: 本文介绍 TiDB 支持的关键字和保留字。 aliases: ['/docs-cn/dev/reference/sql/language-structure/keywords-and-reserved-words/'] --- +本文介绍 TiDB 的关键字和保留字,并汇总了所有的关键字以供查询使用。 + # 关键字和保留字 -关键字在 SQL 中有特殊的意义, 例如 `SELECT`,`UPDATE`,`DELETE`,在作为表名跟函数名的时候,需要特殊对待,例如作为表名,保留字需要被反引号包住: +关键字在 SQL 中有特殊的意义,例如 `SELECT`,`UPDATE`,`DELETE` 等等。它们之中有的能够直接作为模式对象名,被称为**非保留关键字**(简称**关键字**),但有的需要经过特殊处理才能作为模式对象名,被称为**保留关键字**(简称**保留字**)。 + +对于保留字,必须使用反引号 `\`` 包裹,才能作为模式对象名被使用。例如: {{< copyable "sql" >}} @@ -28,7 +33,7 @@ CREATE TABLE `select` (a INT); Query OK, 0 rows affected (0.09 sec) ``` -`BEGIN` 和 `END` 是关键字, 但不是保留字,所以不需要反引号: +而关键字则不需要反引号也能直接作为模式对象名。例如 `BEGIN` 和 `END` 是关键字,但不是保留字,所以以下语句能够正常执行: {{< copyable "sql" >}} @@ -40,7 +45,7 @@ CREATE TABLE `select` (BEGIN int, END int); Query OK, 0 rows affected (0.09 sec) ``` -有一种特殊情况, 如果使用了限定符 `.`,那么也不需要用反引号: +有一种特殊情况,如果使用了限定符 `.`,那么也不需要用反引号: {{< copyable "sql" >}} @@ -58,77 +63,112 @@ Query OK, 0 rows affected (0.08 sec) A +- ACCOUNT - ACTION - ADD (R) -- ADDDATE -- ADMIN +- ADMIN (R) +- ADVISE - AFTER +- AGAINST +- AGO +- ALGORITHM - ALL (R) - ALTER (R) - ALWAYS -- ANALYZE(R) +- ANALYZE (R) - AND (R) - ANY - AS (R) - ASC (R) - ASCII +- AUTO_ID_CACHE - AUTO_INCREMENT - AUTO_RANDOM +- AUTO_RANDOM_BASE - AVG - AVG_ROW_LENGTH B +- BACKEND +- BACKUP +- BACKUPS - BEGIN - BETWEEN (R) - BIGINT (R) - BINARY (R) +- BINDING +- BINDINGS - BINLOG - BIT -- BIT_XOR - BLOB (R) +- BLOCK - BOOL - BOOLEAN - BOTH (R) - BTREE +- BUCKETS (R) +- BUILTINS (R) - BY (R) - BYTE C +- CACHE +- CANCEL (R) +- CAPTURE - CASCADE (R) +- CASCADED - CASE (R) -- CAST +- CHAIN - CHANGE (R) - CHAR (R) - CHARACTER (R) - CHARSET - CHECK (R) +- CHECKPOINT - CHECKSUM +- CIPHER +- CLEANUP +- CLIENT +- CMSKETCH (R) - COALESCE - COLLATE (R) - COLLATION - COLUMN (R) - COLUMNS +- COLUMN_FORMAT - COMMENT - COMMIT - COMMITTED - COMPACT - COMPRESSED - COMPRESSION +- CONCURRENCY +- CONFIG - CONNECTION - CONSISTENT - CONSTRAINT (R) +- CONTEXT - CONVERT (R) -- COUNT +- CPU - CREATE (R) - CROSS (R) +- CSV_BACKSLASH_ESCAPE +- CSV_DELIMITER +- CSV_HEADER +- CSV_NOT_NULL +- CSV_NULL +- CSV_SEPARATOR +- CSV_TRIM_LAST_SEPARATORS - CUME_DIST (R-Window) +- CURRENT - CURRENT_DATE (R) +- CURRENT_ROLE (R) - CURRENT_TIME (R) - CURRENT_TIMESTAMP (R) - CURRENT_USER (R) -- CURTIME +- CYCLE D @@ -136,31 +176,34 @@ Query OK, 0 rows affected (0.08 sec) - DATABASE (R) - DATABASES (R) - DATE -- DATE_ADD -- DATE_SUB - DATETIME - DAY - DAY_HOUR (R) - DAY_MICROSECOND (R) - DAY_MINUTE (R) - DAY_SECOND (R) -- DDL +- DDL (R) - DEALLOCATE -- DEC - DECIMAL (R) - DEFAULT (R) -- DELAY_KEY_WRITE +- DEFINER - DELAYED (R) +- DELAY_KEY_WRITE - DELETE (R) - DENSE_RANK (R-Window) +- DEPTH (R) - DESC (R) - DESCRIBE (R) +- DIRECTORY - DISABLE +- DISCARD +- DISK - DISTINCT (R) - DISTINCTROW (R) - DIV (R) - DO - DOUBLE (R) +- DRAINER (R) - DROP (R) - DUAL (R) - DUPLICATE @@ -170,29 +213,42 @@ Query OK, 0 rows affected (0.08 sec) - ELSE (R) - ENABLE -- ENCLOSED +- ENCLOSED (R) +- ENCRYPTION - END +- ENFORCED - ENGINE - ENGINES - ENUM +- ERROR +- ERRORS - ESCAPE -- ESCAPED +- ESCAPED (R) +- EVENT - EVENTS +- EVOLVE +- EXCEPT (R) +- EXCHANGE - EXCLUSIVE - EXECUTE -- EXISTS +- EXISTS (R) +- EXPANSION +- EXPIRE - EXPLAIN (R) -- EXTRACT +- EXTENDED F - FALSE (R) +- FAULTS - FIELDS +- FILE - FIRST - FIRST_VALUE (R-Window) - FIXED - FLOAT (R) - FLUSH +- FOLLOWING - FOR (R) - FORCE (R) - FOREIGN (R) @@ -204,13 +260,12 @@ Query OK, 0 rows affected (0.08 sec) G +- GENERAL - GENERATED (R) -- GET_FORMAT - GLOBAL - GRANT (R) - GRANTS - GROUP (R) -- GROUP_CONCAT - GROUPS (R-Window) H @@ -218,6 +273,8 @@ Query OK, 0 rows affected (0.08 sec) - HASH - HAVING (R) - HIGH_PRIORITY (R) +- HISTORY +- HOSTS - HOUR - HOUR_MICROSECOND (R) - HOUR_MINUTE (R) @@ -228,35 +285,57 @@ Query OK, 0 rows affected (0.08 sec) - IDENTIFIED - IF (R) - IGNORE (R) +- IMPORT +- IMPORTS - IN (R) +- INCREMENT +- INCREMENTAL - INDEX (R) - INDEXES - INFILE (R) - INNER (R) - INSERT (R) +- INSERT_METHOD +- INSTANCE - INT (R) +- INT1 (R) +- INT2 (R) +- INT3 (R) +- INT4 (R) +- INT8 (R) - INTEGER (R) - INTERVAL (R) - INTO (R) +- INVISIBLE +- INVOKER +- IO +- IPC - IS (R) - ISOLATION +- ISSUER J -- JOBS +- JOB (R) +- JOBS (R) - JOIN (R) - JSON K - KEY (R) -- KEY_BLOCK_SIZE - KEYS (R) +- KEY_BLOCK_SIZE - KILL (R) L +- LABELS - LAG (R-Window) +- LANGUAGE +- LAST +- LASTVAL +- LAST_BACKUP - LAST_VALUE (R-Window) - LEAD (R-Window) - LEADING (R) @@ -265,38 +344,48 @@ Query OK, 0 rows affected (0.08 sec) - LEVEL - LIKE (R) - LIMIT (R) +- LINEAR (R) - LINES (R) +- LIST - LOAD (R) - LOCAL - LOCALTIME (R) - LOCALTIMESTAMP (R) +- LOCATION - LOCK (R) +- LOGS +- LONG (R) - LONGBLOB (R) - LONGTEXT (R) - LOW_PRIORITY (R) M -- MAX -- MAX_ROWS +- MASTER +- MATCH (R) - MAXVALUE (R) +- MAX_CONNECTIONS_PER_HOUR +- MAX_IDXNUM +- MAX_MINUTES +- MAX_QUERIES_PER_HOUR +- MAX_ROWS +- MAX_UPDATES_PER_HOUR +- MAX_USER_CONNECTIONS +- MB - MEDIUMBLOB (R) - MEDIUMINT (R) - MEDIUMTEXT (R) +- MEMORY +- MERGE - MICROSECOND -- MIN -- MIN_ROWS - MINUTE - MINUTE_MICROSECOND (R) - MINUTE_SECOND (R) -- MIN +- MINVALUE - MIN_ROWS -- MINUTE -- MINUTE_MICROSECOND -- MINUTE_SECOND - MOD (R) - MODE -- MODIRY +- MODIFY - MONTH N @@ -304,47 +393,79 @@ Query OK, 0 rows affected (0.08 sec) - NAMES - NATIONAL - NATURAL (R) +- NCHAR +- NEVER +- NEXT +- NEXTVAL - NO -- NO_WRITE_TO_BINLOG (R) +- NOCACHE +- NOCYCLE +- NODEGROUP +- NODE_ID (R) +- NODE_STATE (R) +- NOMAXVALUE +- NOMINVALUE - NONE - NOT (R) -- NOW +- NOWAIT +- NO_WRITE_TO_BINLOG (R) - NTH_VALUE (R-Window) - NTILE (R-Window) - NULL (R) +- NULLS - NUMERIC (R) -- NVARCHAR (R) +- NVARCHAR O - OFFSET - ON (R) +- ONLINE - ONLY +- ON_DUPLICATE +- OPEN +- OPTIMISTIC (R) +- OPTIMIZE (R) - OPTION (R) +- OPTIONALLY (R) - OR (R) - ORDER (R) - OUTER (R) +- OUTFILE (R) - OVER (R-Window) P +- PACK_KEYS +- PAGE +- PARSER +- PARTIAL - PARTITION (R) +- PARTITIONING - PARTITIONS - PASSWORD - PERCENT_RANK (R-Window) +- PER_DB +- PER_TABLE +- PESSIMISTIC (R) - PLUGINS -- POSITION +- PRECEDING - PRECISION (R) - PREPARE +- PRE_SPLIT_REGIONS - PRIMARY (R) - PRIVILEGES - PROCEDURE (R) - PROCESS - PROCESSLIST +- PROFILE +- PROFILES +- PUMP (R) Q - QUARTER +- QUERIES - QUERY - QUICK @@ -352,98 +473,164 @@ Query OK, 0 rows affected (0.08 sec) - RANGE (R) - RANK (R-Window) +- RATE_LIMIT - READ (R) - REAL (R) +- REBUILD +- RECOVER - REDUNDANT - REFERENCES (R) - REGEXP (R) +- REGION (R) +- REGIONS (R) +- RELEASE (R) +- RELOAD +- REMOVE - RENAME (R) +- REORGANIZE +- REPAIR - REPEAT (R) - REPEATABLE - REPLACE (R) +- REPLICA +- REPLICATION +- REQUIRE (R) +- RESPECT +- RESTORE +- RESTORES - RESTRICT (R) - REVERSE - REVOKE (R) - RIGHT (R) - RLIKE (R) +- ROLE - ROLLBACK -- ROW +- ROUTINE +- ROW (R) +- ROWS (R-Window) - ROW_COUNT - ROW_FORMAT - ROW_NUMBER (R-Window) -- ROWS (R-Window) +- RTREE S -- SCHEMA -- SCHEMAS +- SAMPLES (R) - SECOND +- SECONDARY_ENGINE +- SECONDARY_LOAD +- SECONDARY_UNLOAD - SECOND_MICROSECOND (R) +- SECURITY - SELECT (R) +- SEND_CREDENTIALS_TO_TIKV +- SEPARATOR +- SEQUENCE +- SERIAL - SERIALIZABLE - SESSION - SET (R) +- SETVAL +- SHARD_ROW_ID_BITS - SHARE - SHARED - SHOW (R) +- SHUTDOWN - SIGNED +- SIMPLE +- SKIP_SCHEMA_FILES +- SLAVE +- SLOW - SMALLINT (R) - SNAPSHOT - SOME +- SOURCE +- SPATIAL (R) +- SPLIT (R) +- SQL (R) +- SQL_BIG_RESULT (R) +- SQL_BUFFER_RESULT - SQL_CACHE - SQL_CALC_FOUND_ROWS (R) - SQL_NO_CACHE +- SQL_SMALL_RESULT (R) +- SQL_TSI_DAY +- SQL_TSI_HOUR +- SQL_TSI_MINUTE +- SQL_TSI_MONTH +- SQL_TSI_QUARTER +- SQL_TSI_SECOND +- SQL_TSI_WEEK +- SQL_TSI_YEAR +- SSL (R) - START - STARTING (R) -- STATS -- STATS_BUCKETS -- STATS_HISTOGRAMS -- STATS_META +- STATS (R) +- STATS_AUTO_RECALC +- STATS_BUCKETS (R) +- STATS_HEALTHY (R) +- STATS_HISTOGRAMS (R) +- STATS_META (R) - STATS_PERSISTENT +- STATS_SAMPLE_PAGES - STATUS +- STORAGE - STORED (R) -- SUBDATE -- SUBSTR -- SUBSTRING -- SUM +- STRAIGHT_JOIN (R) +- STRICT_FORMAT +- SUBJECT +- SUBPARTITION +- SUBPARTITIONS - SUPER +- SWAPS +- SWITCHES +- SYSTEM_TIME T - TABLE (R) - TABLES +- TABLESPACE +- TABLE_CHECKSUM +- TEMPORARY +- TEMPTABLE - TERMINATED (R) - TEXT - THAN - THEN (R) -- TIDB -- TIDB_INLJ -- TIDB_SMJ +- TIDB (R) +- TIFLASH (R) +- TIKV_IMPORTER - TIME - TIMESTAMP -- TIMESTAMPADD -- TIMESTAMPDIFF - TINYBLOB (R) - TINYINT (R) - TINYTEXT (R) - TO (R) +- TOPN (R) +- TRACE +- TRADITIONAL - TRAILING (R) - TRANSACTION - TRIGGER (R) - TRIGGERS -- TRIM - TRUE (R) - TRUNCATE +- TYPE U +- UNBOUNDED - UNCOMMITTED +- UNDEFINED +- UNICODE - UNION (R) - UNIQUE (R) - UNKNOWN - UNLOCK (R) - UNSIGNED (R) - UPDATE (R) +- USAGE (R) - USE (R) - USER - USING (R) @@ -453,26 +640,34 @@ Query OK, 0 rows affected (0.08 sec) V +- VALIDATION - VALUE - VALUES (R) - VARBINARY (R) - VARCHAR (R) +- VARCHARACTER (R) - VARIABLES +- VARYING (R) - VIEW - VIRTUAL (R) +- VISIBLE W - WARNINGS - WEEK +- WEIGHT_STRING - WHEN (R) - WHERE (R) +- WIDTH (R) - WINDOW (R-Window) - WITH (R) +- WITHOUT - WRITE (R) X +- X509 - XOR (R) Y From eadb71e625327ccbfa79c1360f9d321a799ed808 Mon Sep 17 00:00:00 2001 From: tangenta Date: Fri, 22 May 2020 14:44:40 +0800 Subject: [PATCH 2/6] address comments --- keywords-and-reserved-words.md => keywords.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) rename keywords-and-reserved-words.md => keywords.md (90%) diff --git a/keywords-and-reserved-words.md b/keywords.md similarity index 90% rename from keywords-and-reserved-words.md rename to keywords.md index 3826b3463e41..97811db2bf1c 100644 --- a/keywords-and-reserved-words.md +++ b/keywords.md @@ -1,17 +1,17 @@ --- -title: 关键字和保留字 +title: 关键字 category: reference -summary: 本文介绍 TiDB 支持的关键字和保留字。 -aliases: ['/docs-cn/dev/reference/sql/language-structure/keywords-and-reserved-words/'] +summary: 本文介绍 TiDB 的关键字。 +aliases: ['/docs-cn/dev/reference/sql/language-structure/keywords/'] --- -本文介绍 TiDB 的关键字和保留字,并汇总了所有的关键字以供查询使用。 +# 关键字 -# 关键字和保留字 +本文介绍 TiDB 的关键字,对保留字和非保留字作出区分,并汇总所有的关键字以供查询使用。 -关键字在 SQL 中有特殊的意义,例如 `SELECT`,`UPDATE`,`DELETE` 等等。它们之中有的能够直接作为模式对象名,被称为**非保留关键字**(简称**关键字**),但有的需要经过特殊处理才能作为模式对象名,被称为**保留关键字**(简称**保留字**)。 +关键字是 SQL 语句中具有特殊含义的单词,例如 `SELECT`,`UPDATE`,`DELETE` 等等。它们之中有的能够直接作为标识符,被称为**非保留关键字**(简称**非保留字**),但有的需要经过特殊处理才能作为标识符,被称为**保留关键字**(简称**保留字**)。 -对于保留字,必须使用反引号 `\`` 包裹,才能作为模式对象名被使用。例如: +对于保留字,必须使用反引号包裹,才能作为标识符被使用。例如: {{< copyable "sql" >}} @@ -33,7 +33,7 @@ CREATE TABLE `select` (a INT); Query OK, 0 rows affected (0.09 sec) ``` -而关键字则不需要反引号也能直接作为模式对象名。例如 `BEGIN` 和 `END` 是关键字,但不是保留字,所以以下语句能够正常执行: +而非保留字则不需要反引号也能直接作为标识符。例如 `BEGIN` 和 `END` 是非保留字,以下语句能够正常执行: {{< copyable "sql" >}} @@ -57,7 +57,7 @@ CREATE TABLE test.select (BEGIN int, END int); Query OK, 0 rows affected (0.08 sec) ``` -下表列出了 TiDB 中的关键字和保留字。保留字用 `(R)` 来标识。[窗口函数](/functions-and-operators/window-functions.md)的保留字用 `(R-Window)` 来标识: +下表列出了 TiDB 中所有的关键字。其中保留字用 `(R)` 来标识。[窗口函数](/functions-and-operators/window-functions.md)的保留字用 `(R-Window)` 来标识: {{< tabs-panel "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z" >}} From 1e4dc4ba9931037cd30a852c3cc620b48dcafcc0 Mon Sep 17 00:00:00 2001 From: tangenta Date: Fri, 22 May 2020 14:47:50 +0800 Subject: [PATCH 3/6] fix deadlink --- TOC.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TOC.md b/TOC.md index 2741178e6096..da66321520ae 100644 --- a/TOC.md +++ b/TOC.md @@ -221,7 +221,7 @@ + [AUTO_RANDOM](/auto-random.md) @谢腾进 + [字面值](/literal-values.md) @邰凌翔 + [Schema 对象名](/schema-object-names.md) @邰凌翔 - + [关键字和保留字](/keywords-and-reserved-words.md) @@邰凌翔 + + [关键字](/keywords.md) @@邰凌翔 + [用户自定义变量](/user-defined-variables.md) @邰凌翔 + [表达式语法](/expression-syntax.md) @邰凌翔 + [注释语法](/comment-syntax.md) @邰凌翔 From a8045935507f98cb4aba5781f72e4ad249715049 Mon Sep 17 00:00:00 2001 From: TomShawn <41534398+TomShawn@users.noreply.github.com> Date: Fri, 22 May 2020 15:29:48 +0800 Subject: [PATCH 4/6] modify alias --- keywords.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keywords.md b/keywords.md index 97811db2bf1c..c03deb7401ae 100644 --- a/keywords.md +++ b/keywords.md @@ -2,7 +2,7 @@ title: 关键字 category: reference summary: 本文介绍 TiDB 的关键字。 -aliases: ['/docs-cn/dev/reference/sql/language-structure/keywords/'] +aliases: ['/docs-cn/dev/keywords-and-reserved-words/'] --- # 关键字 From e3c7bad3221b9bd99f3d2fa87d03688739aff764 Mon Sep 17 00:00:00 2001 From: tangenta Date: Mon, 25 May 2020 16:33:43 +0800 Subject: [PATCH 5/6] address comment --- keywords.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keywords.md b/keywords.md index c03deb7401ae..d286c1b23e2b 100644 --- a/keywords.md +++ b/keywords.md @@ -9,7 +9,7 @@ aliases: ['/docs-cn/dev/keywords-and-reserved-words/'] 本文介绍 TiDB 的关键字,对保留字和非保留字作出区分,并汇总所有的关键字以供查询使用。 -关键字是 SQL 语句中具有特殊含义的单词,例如 `SELECT`,`UPDATE`,`DELETE` 等等。它们之中有的能够直接作为标识符,被称为**非保留关键字**(简称**非保留字**),但有的需要经过特殊处理才能作为标识符,被称为**保留关键字**(简称**保留字**)。 +关键字是 SQL 语句中具有特殊含义的单词,例如 `SELECT`,`UPDATE`,`DELETE` 等等。它们之中有的能够直接作为标识符,被称为**非保留关键字**(简称**非保留字**),但有需要经过特殊处理才能作为标识符的字,被称为**保留关键字**(简称**保留字**)。 对于保留字,必须使用反引号包裹,才能作为标识符被使用。例如: From c299317ff3d1cdfeb3f535b312d5d367f96ed134 Mon Sep 17 00:00:00 2001 From: TomShawn <41534398+TomShawn@users.noreply.github.com> Date: Mon, 25 May 2020 17:37:44 +0800 Subject: [PATCH 6/6] Update keywords.md --- keywords.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keywords.md b/keywords.md index d286c1b23e2b..a7ccd77e93dc 100644 --- a/keywords.md +++ b/keywords.md @@ -2,7 +2,7 @@ title: 关键字 category: reference summary: 本文介绍 TiDB 的关键字。 -aliases: ['/docs-cn/dev/keywords-and-reserved-words/'] +aliases: ['/docs-cn/dev/keywords-and-reserved-words/','/docs-cn/dev/reference/sql/language-structure/keywords-and-reserved-words/'] --- # 关键字