title | summary | category |
---|---|---|
Keywords and Reserved Words |
Learn about the keywords and reserved words in TiDB. |
user guide |
Keywords are words that have significance in SQL. Certain keywords, such as SELECT
, UPDATE
, or DELETE
, are reserved and require special treatment for use as identifiers such as table and column names. For example, as table names, the reserved words must be quoted with backquotes:
mysql> CREATE TABLE select (a INT);
ERROR 1105 (HY000): line 0 column 19 near " (a INT)" (total length 27)
mysql> CREATE TABLE `select` (a INT);
Query OK, 0 rows affected (0.09 sec)
The BEGIN
and END
are keywords but not reserved words, so you do not need to quote them with backquotes:
mysql> CREATE TABLE `select` (BEGIN int, END int);
Query OK, 0 rows affected (0.09 sec)
Exception: A word that follows a period .
qualifier does not need to be quoted with backquotes either:
mysql> CREATE TABLE test.select (BEGIN int, END int);
Query OK, 0 rows affected (0.08 sec)
The following table lists the keywords and reserved words in TiDB. The reserved words are labelled with (R).
ACTION | ADD (R) | ADDDATE |
---|---|---|
ADMIN | AFTER | ALL (R) |
ALTER (R) | ALWAYS | ANALYZE(R) |
AND (R) | ANY | AS (R) |
ASC (R) | ASCII | AUTO_INCREMENT |
AVG | AVG_ROW_LENGTH | BEGIN |
BETWEEN (R) | BIGINT (R) | BINARY (R) |
BINLOG | BIT | BIT_XOR |
BLOB (R) | BOOL | BOOLEAN |
BOTH (R) | BTREE | BY (R) |
BYTE | CASCADE (R) | CASE (R) |
CAST | CHANGE (R) | CHAR (R) |
CHARACTER (R) | CHARSET | CHECK (R) |
CHECKSUM | COALESCE | COLLATE (R) |
COLLATION | COLUMN (R) | COLUMNS |
COMMENT | COMMIT | COMMITTED |
COMPACT | COMPRESSED | COMPRESSION |
CONNECTION | CONSISTENT | CONSTRAINT (R) |
CONVERT (R) | COUNT | CREATE (R) |
CROSS (R) | CURRENT_DATE (R) | CURRENT_TIME (R) |
CURRENT_TIMESTAMP (R) | CURRENT_USER (R) | CURTIME |
DATA | DATABASE (R) | DATABASES (R) |
DATE | DATE_ADD | DATE_SUB |
DATETIME | DAY | DAY_HOUR (R) |
DAY_MICROSECOND (R) | DAY_MINUTE (R) | DAY_SECOND (R) |
DDL | DEALLOCATE | DEC |
DECIMAL (R) | DEFAULT (R) | DELAY_KEY_WRITE |
DELAYED (R) | DELETE (R) | DESC (R) |
DESCRIBE (R) | DISABLE | DISTINCT (R) |
DISTINCTROW (R) | DIV (R) | DO |
DOUBLE (R) | DROP (R) | DUAL (R) |
DUPLICATE | DYNAMIC | ELSE (R) |
ENABLE | ENCLOSED | END |
ENGINE | ENGINES | ENUM |
ESCAPE | ESCAPED | EVENTS |
EXCLUSIVE | EXECUTE | EXISTS |
EXPLAIN (R) | EXTRACT | FALSE (R) |
FIELDS | FIRST | FIXED |
FLOAT (R) | FLUSH | FOR (R) |
FORCE (R) | FOREIGN (R) | FORMAT |
FROM (R) | FULL | FULLTEXT (R) |
FUNCTION | GENERATED (R) | GET_FORMAT |
GLOBAL | GRANT (R) | GRANTS |
GROUP (R) | GROUP_CONCAT | HASH |
HAVING (R) | HIGH_PRIORITY (R) | HOUR |
HOUR_MICROSECOND (R) | HOUR_MINUTE (R) | HOUR_SECOND (R) |
IDENTIFIED | IF (R) | IGNORE (R) |
IN (R) | INDEX (R) | INDEXES |
INFILE (R) | INNER (R) | INSERT (R) |
INT (R) | INTEGER (R) | INTERVAL (R) |
INTO (R) | IS (R) | ISOLATION |
JOBS | JOIN (R) | JSON |
KEY (R) | KEY_BLOCK_SIZE | KEYS (R) |
KILL (R) | LEADING (R) | LEFT (R) |
LESS | LEVEL | LIKE (R) |
LIMIT (R) | LINES (R) | LOAD (R) |
LOCAL | LOCALTIME (R) | LOCALTIMESTAMP (R) |
LOCK (R) | LONGBLOB (R) | LONGTEXT (R) |
LOW_PRIORITY (R) | MAX | MAX_ROWS |
MAXVALUE (R) | MEDIUMBLOB (R) | MEDIUMINT (R) |
MEDIUMTEXT (R) | MICROSECOND | MIN |
MIN_ROWS | MINUTE | MINUTE_MICROSECOND (R) |
MINUTE_SECOND (R) | MIN | MIN_ROWS |
MINUTE | MINUTE_MICROSECOND | MINUTE_SECOND |
MOD (R) | MODE | MODIRY |
MONTH | NAMES | NATIONAL |
NATURAL (R) | NO | NO_WRITE_TO_BINLOG (R) |
NONE | NOT (R) | NOW |
NULL (R) | NUMERIC (R) | NVARCHAR (R) |
OFFSET | ON (R) | ONLY |
OPTION (R) | OR (R) | ORDER (R) |
OUTER (R) | PARTITION (R) | PARTITIONS |
PASSWORD | PLUGINS | POSITION |
PRECISION (R) | PREPARE | PRIMARY (R) |
PRIVILEGES | PROCEDURE (R) | PROCESS |
PROCESSLIST | QUARTER | QUERY |
QUICK | RANGE (R) | READ (R) |
REAL (R) | REDUNDANT | REFERENCES (R) |
REGEXP (R) | RENAME (R) | REPEAT (R) |
REPEATABLE | REPLACE (R) | RESTRICT (R) |
REVERSE | REVOKE (R) | RIGHT (R) |
RLIKE (R) | ROLLBACK | ROW |
ROW_COUNT | ROW_FORMAT | SCHEMA |
SCHEMAS | SECOND | SECOND_MICROSECOND (R) |
SELECT (R) | SERIALIZABLE | SESSION |
SET (R) | SHARE | SHARED |
SHOW (R) | SIGNED | SMALLINT (R) |
SNAPSHOT | SOME | SQL_CACHE |
SQL_CALC_FOUND_ROWS (R) | SQL_NO_CACHE | START |
STARTING (R) | STATS | STATS_BUCKETS |
STATS_HISTOGRAMS | STATS_META | STATS_PERSISTENT |
STATUS | STORED (R) | SUBDATE |
SUBSTR | SUBSTRING | SUM |
SUPER | TABLE (R) | TABLES |
TERMINATED (R) | TEXT | THAN |
THEN (R) | TIDB | TIDB_INLJ |
TIDB_SMJ | TIME | TIMESTAMP |
TIMESTAMPADD | TIMESTAMPDIFF | TINYBLOB (R) |
TINYINT (R) | TINYTEXT (R) | TO (R) |
TRAILING (R) | TRANSACTION | TRIGGER (R) |
TRIGGERS | TRIM | TRUE (R) |
TRUNCATE | UNCOMMITTED | UNION (R) |
UNIQUE (R) | UNKNOWN | UNLOCK (R) |
UNSIGNED (R) | UPDATE (R) | USE (R) |
USER | USING (R) | UTC_DATE (R) |
UTC_TIME (R) | UTC_TIMESTAMP (R) | VALUE |
VALUES (R) | VARBINARY (R) | VARCHAR (R) |
VARIABLES | VIEW | VIRTUAL (R) |
WARNINGS | WEEK | WHEN (R) |
WHERE (R) | WITH (R) | WRITE (R) |
XOR (R) | YEAR | YEAR_MONTH (R) |
ZEROFILL (R) |