Related Documentation Download this Manual
PDF (US Ltr) - 33.4Mb
PDF (A4) - 33.4Mb
PDF (RPM) - 31.3Mb
HTML Download (TGZ) - 7.9Mb
HTML Download (Zip) - 8.0Mb
HTML Download (RPM) - 6.8Mb
Man Pages (TGZ) - 145.1Kb
Man Pages (Zip) - 206.0Kb
Info (Gzip) - 3.1Mb
Info (Zip) - 3.1Mb


MySQL 8.0 Reference Manual  /  Language Structure  /  Keywords and Reserved Words

Pre-General Availability Draft: 2017-09-21

9.3 Keywords and Reserved Words

Keywords are words that have significance in SQL. Certain keywords, such as SELECT, DELETE, or BIGINT, are reserved and require special treatment for use as identifiers such as table and column names. This may also be true for the names of built-in functions.

Nonreserved keywords are permitted as identifiers without quoting. Reserved words are permitted as identifiers if you quote them as described in Section 9.2, “Schema Object Names”:

mysql> CREATE TABLE interval (begin INT, end INT);
ERROR 1064 (42000): You have an error in your SQL syntax ...
near 'interval (begin INT, end INT)'

BEGIN and END are keywords but not reserved, so their use as identifiers does not require quoting. INTERVAL is a reserved keyword and must be quoted to be used as an identifier:

mysql> CREATE TABLE `interval` (begin INT, end INT);
Query OK, 0 rows affected (0.01 sec)

Exception: A word that follows a period in a qualified name must be an identifier, so it need not be quoted even if it is reserved:

mysql> CREATE TABLE mydb.interval (begin INT, end INT);
Query OK, 0 rows affected (0.01 sec)

Names of built-in functions are permitted as identifiers but may require care to be used as such. For example, COUNT is acceptable as a column name. However, by default, no whitespace is permitted in function invocations between the function name and the following ( character. This requirement enables the parser to distinguish whether the name is used in a function call or in nonfunction context. For further details on recognition of function names, see Section 9.2.4, “Function Name Parsing and Resolution”.

The following table shows the keywords and reserved words in MySQL 8.0, along with changes to individual words from version to version. Reserved keywords are marked with (R). In addition, _FILENAME is reserved.

At some point, you might upgrade to a higher version, so it is a good idea to have a look at future reserved words, too. You can find these in the manuals that cover higher versions of MySQL. Most of the reserved words in the table are forbidden by standard SQL as column or table names (for example, GROUP). A few are reserved because MySQL needs them and uses a yacc parser.

Table 9.2 Keywords and Reserved Words in MySQL 8.0

ACCESSIBLE (R) ACCOUNT ACTION
ADD (R) ADMIN (R) AFTER
AGAINST AGGREGATE ALGORITHM
ALL (R) ALTER (R) ALWAYS
ANALYSE[a] ANALYZE (R) AND (R)
ANY AS (R) ASC (R)
ASCII ASENSITIVE (R) AT
AUTOEXTEND_SIZE AUTO_INCREMENT AVG
AVG_ROW_LENGTH BACKUP BEFORE (R)
BEGIN BETWEEN (R) BIGINT (R)
BINARY (R) BINLOG BIT
BLOB (R) BLOCK BOOL
BOOLEAN BOTH (R) BTREE
BUCKETS[b] BY (R) BYTE
CACHE CALL (R) CASCADE (R)
CASCADED CASE (R) CATALOG_NAME
CHAIN CHANGE (R) CHANGED
CHANNEL CHAR (R) CHARACTER (R)
CHARSET CHECK (R) CHECKSUM
CIPHER CLASS_ORIGIN CLIENT
CLONE[c] CLOSE COALESCE
CODE COLLATE (R) COLLATION
COLUMN (R) COLUMNS COLUMN_FORMAT
COLUMN_NAME COMMENT COMMIT
COMMITTED COMPACT COMPLETION
COMPONENT COMPRESSED COMPRESSION
CONCURRENT CONDITION (R) CONNECTION
CONSISTENT CONSTRAINT (R) CONSTRAINT_CATALOG
CONSTRAINT_NAME CONSTRAINT_SCHEMA CONTAINS
CONTEXT CONTINUE (R) CONVERT (R)
CPU CREATE (R) CROSS (R)
CUBE[d] (R) CUME_DIST[e] (R) CURRENT
CURRENT_DATE (R) CURRENT_TIME (R) CURRENT_TIMESTAMP (R)
CURRENT_USER (R) CURSOR (R) CURSOR_NAME
DATA DATABASE (R) DATABASES (R)
DATAFILE DATE DATETIME
DAY DAY_HOUR (R) DAY_MICROSECOND (R)
DAY_MINUTE (R) DAY_SECOND (R) DEALLOCATE
DEC (R) DECIMAL (R) DECLARE (R)
DEFAULT (R) DEFAULT_AUTH DEFINER
DELAYED (R) DELAY_KEY_WRITE DELETE (R)
DENSE_RANK[f] (R) DESC (R) DESCRIBE (R)
DES_KEY_FILE[g] DETERMINISTIC (R) DIAGNOSTICS
DIRECTORY DISABLE DISCARD
DISK DISTINCT (R) DISTINCTROW (R)
DIV (R) DO DOUBLE (R)
DROP (R) DUAL (R) DUMPFILE
DUPLICATE DYNAMIC EACH (R)
ELSE (R) ELSEIF (R) ENABLE
ENCLOSED (R) ENCRYPTION END
ENDS ENGINE ENGINES
ENUM ERROR ERRORS
ESCAPE ESCAPED (R) EVENT
EVENTS EVERY EXCEPT (R)
EXCHANGE EXCLUDE[h] EXECUTE
EXISTS (R) EXIT (R) EXPANSION
EXPIRE EXPLAIN (R) EXPORT
EXTENDED EXTENT_SIZE FALSE (R)
FAST FAULTS FETCH (R)
FIELDS FILE FILE_BLOCK_SIZE
FILTER FIRST FIRST_VALUE[i] (R)
FIXED FLOAT (R) FLOAT4 (R)
FLOAT8 (R) FLUSH FOLLOWING[j]
FOLLOWS FOR (R) FORCE (R)
FOREIGN (R) FORMAT FOUND
FROM (R) FULL FULLTEXT (R)
FUNCTION[k] (R) GENERAL GENERATED (R)
GEOMETRY GEOMETRYCOLLECTION GET (R)
GET_FORMAT GLOBAL GRANT (R)
GRANTS GROUP (R) GROUPING[l] (R)
GROUPS[m] (R) GROUP_REPLICATION HANDLER
HASH HAVING (R) HELP
HIGH_PRIORITY (R) HISTOGRAM[n] HISTORY[o]
HOST HOSTS HOUR
HOUR_MICROSECOND (R) HOUR_MINUTE (R) HOUR_SECOND (R)
IDENTIFIED IF (R) IGNORE (R)
IGNORE_SERVER_IDS IMPORT IN (R)
INDEX (R) INDEXES INFILE (R)
INITIAL_SIZE INNER (R) INOUT (R)
INSENSITIVE (R) INSERT (R) INSERT_METHOD
INSTALL INSTANCE INT (R)
INT1 (R) INT2 (R) INT3 (R)
INT4 (R) INT8 (R) INTEGER (R)
INTERVAL (R) INTO (R) INVISIBLE
INVOKER IO IO_AFTER_GTIDS (R)
IO_BEFORE_GTIDS (R) IO_THREAD IPC
IS (R) ISOLATION ISSUER
ITERATE (R) JOIN (R) JSON
KEY (R) KEYS (R) KEY_BLOCK_SIZE
KILL (R) LAG[p] (R) LANGUAGE
LAST LAST_VALUE[q] (R) LEAD[r] (R)
LEADING (R) LEAVE (R) LEAVES
LEFT (R) LESS LEVEL
LIKE (R) LIMIT (R) LINEAR (R)
LINES (R) LINESTRING LIST
LOAD (R) LOCAL LOCALTIME (R)
LOCALTIMESTAMP (R) LOCK (R) LOCKED[s]
LOCKS LOGFILE LOGS
LONG (R) LONGBLOB (R) LONGTEXT (R)
LOOP (R) LOW_PRIORITY (R) MASTER
MASTER_AUTO_POSITION MASTER_BIND (R) MASTER_CONNECT_RETRY
MASTER_DELAY MASTER_HEARTBEAT_PERIOD MASTER_HOST
MASTER_LOG_FILE MASTER_LOG_POS MASTER_PASSWORD
MASTER_PORT MASTER_RETRY_COUNT MASTER_SERVER_ID
MASTER_SSL MASTER_SSL_CA MASTER_SSL_CAPATH
MASTER_SSL_CERT MASTER_SSL_CIPHER MASTER_SSL_CRL
MASTER_SSL_CRLPATH MASTER_SSL_KEY MASTER_SSL_VERIFY_SERVER_CERT (R)
MASTER_TLS_VERSION MASTER_USER MATCH (R)
MAXVALUE (R) MAX_CONNECTIONS_PER_HOUR MAX_QUERIES_PER_HOUR
MAX_ROWS MAX_SIZE MAX_UPDATES_PER_HOUR
MAX_USER_CONNECTIONS MEDIUM MEDIUMBLOB (R)
MEDIUMINT (R) MEDIUMTEXT (R) MEMORY
MERGE MESSAGE_TEXT MICROSECOND
MIDDLEINT (R) MIGRATE MINUTE
MINUTE_MICROSECOND (R) MINUTE_SECOND (R) MIN_ROWS
MOD (R) MODE MODIFIES (R)
MODIFY MONTH MULTILINESTRING
MULTIPOINT MULTIPOLYGON MUTEX
MYSQL_ERRNO NAME NAMES
NATIONAL NATURAL (R) NCHAR
NDB NDBCLUSTER NEVER
NEW NEXT NO
NODEGROUP NONE NOT (R)
NOWAIT[t] NO_WAIT NO_WRITE_TO_BINLOG (R)
NTH_VALUE[u] (R) NTILE[v] (R) NULL (R)
NULLS[w] NUMBER NUMERIC (R)
NVARCHAR OF[x] (R) OFFSET
ON (R) ONE ONLY
OPEN OPTIMIZE (R) OPTIMIZER_COSTS (R)
OPTION (R) OPTIONALLY (R) OPTIONS
OR (R) ORDER (R) OTHERS[y]
OUT (R) OUTER (R) OUTFILE (R)
OVER[z] (R) OWNER PACK_KEYS
PAGE PARSER PARTIAL
PARTITION (R) PARTITIONING PARTITIONS
PASSWORD PERCENT_RANK[aa] (R) PERSIST (R)
PERSIST_ONLY[ab] (R) PHASE PLUGIN
PLUGINS PLUGIN_DIR POINT
POLYGON PORT PRECEDES
PRECEDING[ac] PRECISION (R) PREPARE
PRESERVE PREV PRIMARY (R)
PRIVILEGES PROCEDURE (R) PROCESSLIST
PROFILE PROFILES PROXY
PURGE (R) QUARTER QUERY
QUICK RANGE (R) RANK[ad] (R)
READ (R) READS (R) READ_ONLY
READ_WRITE (R) REAL (R) REBUILD
RECOVER RECURSIVE[ae] (R) REDOFILE[af]
REDO_BUFFER_SIZE REDUNDANT REFERENCES (R)
REGEXP (R) RELAY RELAYLOG
RELAY_LOG_FILE RELAY_LOG_POS RELAY_THREAD
RELEASE (R) RELOAD REMOTE[ag]
REMOVE RENAME (R) REORGANIZE
REPAIR REPEAT (R) REPEATABLE
REPLACE (R) REPLICATE_DO_DB REPLICATE_DO_TABLE
REPLICATE_IGNORE_DB REPLICATE_IGNORE_TABLE REPLICATE_REWRITE_DB
REPLICATE_WILD_DO_TABLE REPLICATE_WILD_IGNORE_TABLE REPLICATION
REQUIRE (R) RESET RESIGNAL (R)
RESOURCE[ah] RESPECT[ai] RESTORE
RESTRICT (R) RESUME RETURN (R)
RETURNED_SQLSTATE RETURNS REUSE[aj]
REVERSE REVOKE (R) RIGHT (R)
RLIKE (R) ROLE[ak] ROLLBACK
ROLLUP ROTATE ROUTINE
ROW[al] (R) ROWS[am] (R) ROW_COUNT
ROW_FORMAT ROW_NUMBER[an] (R) RTREE
SAVEPOINT SCHEDULE SCHEMA (R)
SCHEMAS (R) SCHEMA_NAME SECOND
SECOND_MICROSECOND (R) SECURITY SELECT (R)
SENSITIVE (R) SEPARATOR (R) SERIAL
SERIALIZABLE SERVER SESSION
SET (R) SHARE SHOW (R)
SHUTDOWN SIGNAL (R) SIGNED
SIMPLE SKIP[ao] SLAVE
SLOW SMALLINT (R) SNAPSHOT
SOCKET SOME SONAME
SOUNDS SOURCE SPATIAL (R)
SPECIFIC (R) SQL (R) SQLEXCEPTION (R)
SQLSTATE (R) SQLWARNING (R) SQL_AFTER_GTIDS
SQL_AFTER_MTS_GAPS SQL_BEFORE_GTIDS SQL_BIG_RESULT (R)
SQL_BUFFER_RESULT SQL_CACHE[ap] SQL_CALC_FOUND_ROWS (R)
SQL_NO_CACHE SQL_SMALL_RESULT (R) SQL_THREAD
SQL_TSI_DAY SQL_TSI_HOUR SQL_TSI_MINUTE
SQL_TSI_MONTH SQL_TSI_QUARTER SQL_TSI_SECOND
SQL_TSI_WEEK SQL_TSI_YEAR SRID[aq]
SSL (R) STACKED START
STARTING (R) STARTS STATS_AUTO_RECALC
STATS_PERSISTENT STATS_SAMPLE_PAGES STATUS
STOP STORAGE STORED (R)
STRAIGHT_JOIN (R) STRING SUBCLASS_ORIGIN
SUBJECT SUBPARTITION SUBPARTITIONS
SUPER SUSPEND SWAPS
SWITCHES SYSTEM[ar] (R) TABLE (R)
TABLES TABLESPACE TABLE_CHECKSUM
TABLE_NAME TEMPORARY TEMPTABLE
TERMINATED (R) TEXT THAN
THEN (R) THREAD_PRIORITY[as] TIES[at]
TIME TIMESTAMP TIMESTAMPADD
TIMESTAMPDIFF TINYBLOB (R) TINYINT (R)
TINYTEXT (R) TO (R) TRAILING (R)
TRANSACTION TRIGGER (R) TRIGGERS
TRUE (R) TRUNCATE TYPE
TYPES UNBOUNDED[au] UNCOMMITTED
UNDEFINED UNDO (R) UNDOFILE
UNDO_BUFFER_SIZE UNICODE UNINSTALL
UNION (R) UNIQUE (R) UNKNOWN
UNLOCK (R) UNSIGNED (R) UNTIL
UPDATE (R) UPGRADE USAGE (R)
USE (R) USER USER_RESOURCES
USE_FRM USING (R) UTC_DATE (R)
UTC_TIME (R) UTC_TIMESTAMP (R) VALIDATION
VALUE VALUES (R) VARBINARY (R)
VARCHAR (R) VARCHARACTER (R) VARIABLES
VARYING (R) VCPU[av] VIEW
VIRTUAL (R) VISIBLE WAIT
WARNINGS WEEK WEIGHT_STRING
WHEN (R) WHERE (R) WHILE (R)
WINDOW[aw] (R) WITH (R) WITHOUT
WORK WRAPPER WRITE (R)
X509 XA XID
XML XOR (R) YEAR
YEAR_MONTH (R) ZEROFILL (R)  

[a] ANALYSE: removed in 8.0.1

[b] BUCKETS: added in 8.0.2 (nonreserved)

[c] CLONE: added in 8.0.3 (nonreserved)

[d] CUBE: became reserved in 8.0.1

[e] CUME_DIST: added in 8.0.2 (reserved)

[f] DENSE_RANK: added in 8.0.2 (reserved)

[g] DES_KEY_FILE: removed in 8.0.3

[h] EXCLUDE: added in 8.0.2 (nonreserved)

[i] FIRST_VALUE: added in 8.0.2 (reserved)

[j] FOLLOWING: added in 8.0.2 (nonreserved)

[k] FUNCTION: became reserved in 8.0.1

[l] GROUPING: added in 8.0.1 (reserved)

[m] GROUPS: added in 8.0.2 (reserved)

[n] HISTOGRAM: added in 8.0.2 (nonreserved)

[o] HISTORY: added in 8.0.3 (nonreserved)

[p] LAG: added in 8.0.2 (reserved)

[q] LAST_VALUE: added in 8.0.2 (reserved)

[r] LEAD: added in 8.0.2 (reserved)

[s] LOCKED: added in 8.0.1 (nonreserved)

[t] NOWAIT: added in 8.0.1 (nonreserved)

[u] NTH_VALUE: added in 8.0.2 (reserved)

[v] NTILE: added in 8.0.2 (reserved)

[w] NULLS: added in 8.0.2 (nonreserved)

[x] OF: added in 8.0.1 (reserved)

[y] OTHERS: added in 8.0.2 (nonreserved)

[z] OVER: added in 8.0.2 (reserved)

[aa] PERCENT_RANK: added in 8.0.2 (reserved)

[ab] PERSIST_ONLY: added in 8.0.2 (reserved)

[ac] PRECEDING: added in 8.0.2 (nonreserved)

[ad] RANK: added in 8.0.2 (reserved)

[ae] RECURSIVE: added in 8.0.1 (reserved)

[af] REDOFILE: removed in 8.0.3

[ag] REMOTE: added in 8.0.3 (nonreserved)

[ah] RESOURCE: added in 8.0.3 (nonreserved)

[ai] RESPECT: added in 8.0.2 (nonreserved)

[aj] REUSE: added in 8.0.3 (nonreserved)

[ak] ROLE: became nonreserved in 8.0.1

[al] ROW: became reserved in 8.0.2

[am] ROWS: became reserved in 8.0.2

[an] ROW_NUMBER: added in 8.0.2 (reserved)

[ao] SKIP: added in 8.0.1 (nonreserved)

[ap] SQL_CACHE: removed in 8.0.3

[aq] SRID: added in 8.0.3 (nonreserved)

[ar] SYSTEM: added in 8.0.3 (reserved)

[as] THREAD_PRIORITY: added in 8.0.3 (nonreserved)

[at] TIES: added in 8.0.2 (nonreserved)

[au] UNBOUNDED: added in 8.0.2 (nonreserved)

[av] VCPU: added in 8.0.3 (nonreserved)

[aw] WINDOW: added in 8.0.2 (reserved)


The following table shows the keywords and reserved words that are added in MySQL 8.0. Reserved keywords are marked with (R).

Table 9.3 Keywords and Reserved Words Added in MySQL 8.0 Compared to MySQL 5.7

ADMIN (R) BUCKETS CLONE
COMPONENT CUME_DIST (R) DENSE_RANK (R)
EXCEPT (R) EXCLUDE FIRST_VALUE (R)
FOLLOWING GROUPING (R) GROUPS (R)
HISTOGRAM HISTORY INVISIBLE
LAG (R) LAST_VALUE (R) LEAD (R)
LOCKED NOWAIT NTH_VALUE (R)
NTILE (R) NULLS OF (R)
OTHERS OVER (R) PERCENT_RANK (R)
PERSIST (R) PERSIST_ONLY (R) PRECEDING
RANK (R) RECURSIVE (R) REMOTE
RESOURCE RESPECT REUSE
ROLE ROW_NUMBER (R) SKIP
SRID SYSTEM (R) THREAD_PRIORITY
TIES UNBOUNDED VCPU
VISIBLE WINDOW (R)  

The following table shows the keywords and reserved words that are removed in MySQL 8.0. Reserved keywords are marked with (R).

Table 9.4 Keywords and Reserved Words Removed in MySQL 8.0 Compared to MySQL 5.7

ANALYSE DES_KEY_FILE PARSE_GCOL_EXPR
REDOFILE SQL_CACHE  


User Comments
Sign Up Login You must be logged in to post a comment.