Keywords and Reserved Words

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 list shows the keywords and reserved words in TiDB. Most of the reserved words are labelled with (R). Window functions' reserved words are labelled with (R-Window).

A
  • 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
B
  • BEGIN
  • BETWEEN (R)
  • BIGINT (R)
  • BINARY (R)
  • BINLOG
  • BIT
  • BIT_XOR
  • BLOB (R)
  • BOOL
  • BOOLEAN
  • BOTH (R)
  • BTREE
  • BY (R)
  • BYTE
C
  • 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)
  • CUME_DIST (R-Window)
  • CURRENT_DATE (R)
  • CURRENT_TIME (R)
  • CURRENT_TIMESTAMP (R)
  • CURRENT_USER (R)
  • CURTIME
D
  • 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)
  • DENSE_RANK (R-Window)
  • DESC (R)
  • DESCRIBE (R)
  • DISABLE
  • DISTINCT (R)
  • DISTINCTROW (R)
  • DIV (R)
  • DO
  • DOUBLE (R)
  • DROP (R)
  • DUAL (R)
  • DUPLICATE
  • DYNAMIC
E
  • ELSE (R)
  • ENABLE
  • ENCLOSED
  • END
  • ENGINE
  • ENGINES
  • ENUM
  • ESCAPE
  • ESCAPED
  • EVENTS
  • EXCLUSIVE
  • EXECUTE
  • EXISTS
  • EXPLAIN (R)
  • EXTRACT
F
  • FALSE (R)
  • FIELDS
  • FIRST
  • FIRST_VALUE (R-Window)
  • FIXED
  • FLOAT (R)
  • FLUSH
  • FOR (R)
  • FORCE (R)
  • FOREIGN (R)
  • FORMAT
  • FROM (R)
  • FULL
  • FULLTEXT (R)
  • FUNCTION
G
  • GENERATED (R)
  • GET_FORMAT
  • GLOBAL
  • GRANT (R)
  • GRANTS
  • GROUP (R)
  • GROUP_CONCAT
  • GROUPS (R-Window)
H
  • HASH
  • HAVING (R)
  • HIGH_PRIORITY (R)
  • HOUR
  • HOUR_MICROSECOND (R)
  • HOUR_MINUTE (R)
  • HOUR_SECOND (R)
I
  • 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
J
  • JOBS
  • JOIN (R)
  • JSON
K
  • KEY (R)
  • KEY_BLOCK_SIZE
  • KEYS (R)
  • KILL (R)
L
  • LAG (R-Window)
  • LAST_VALUE (R-Window)
  • LEAD (R-Window)
  • 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)
M
  • 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
N
  • NAMES
  • NATIONAL
  • NATURAL (R)
  • NO
  • NO_WRITE_TO_BINLOG (R)
  • NONE
  • NOT (R)
  • NOW
  • NTH_VALUE (R-Window)
  • NTILE (R-Window)
  • NULL (R)
  • NUMERIC (R)
  • NVARCHAR (R)
O
  • OFFSET
  • ON (R)
  • ONLY
  • OPTION (R)
  • OR (R)
  • ORDER (R)
  • OUTER (R)
  • OVER (R-Window)
P
  • PARTITION (R)
  • PARTITIONS
  • PASSWORD
  • PERCENT_RANK (R-Window)
  • PLUGINS
  • POSITION
  • PRECISION (R)
  • PREPARE
  • PRIMARY (R)
  • PRIVILEGES
  • PROCEDURE (R)
  • PROCESS
  • PROCESSLIST
Q
  • QUARTER
  • QUERY
  • QUICK
R
  • RANGE (R)
  • RANK (R-Window)
  • 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
  • ROW_NUMBER (R-Window)
  • ROWS (R-Window)
S
  • 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
T
  • 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
U
  • 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)
V
  • VALUE
  • VALUES (R)
  • VARBINARY (R)
  • VARCHAR (R)
  • VARIABLES
  • VIEW
  • VIRTUAL (R)
W
  • WARNINGS
  • WEEK
  • WHEN (R)
  • WHERE (R)
  • WINDOW (R-Window)
  • WITH (R)
  • WRITE (R)
X
  • XOR (R)
Y
  • YEAR
  • YEAR_MONTH (R)
Z
  • ZEROFILL (R)