28.3.17 INFORMATION_SCHEMA KEYWORDS 表
The KEYWORDS
table lists the words considered keywords by MySQL and, for each one, indicates whether it is reserved. Reserved keywords may require special treatment in some contexts, such as special quoting when used as identifiers (see Section 11.3, “Keywords and Reserved Words”). This table provides applications a runtime source of MySQL keyword information.
The KEYWORDS
table has these columns:
-
WORD
The keyword.
-
RESERVED
An integer indicating whether the keyword is reserved (1) or nonreserved (0).
These queries lists all keywords, all reserved keywords, and all nonreserved keywords, respectively:
SELECT * FROM INFORMATION_SCHEMA.KEYWORDS;
SELECT WORD FROM INFORMATION_SCHEMA.KEYWORDS WHERE RESERVED = 1;
SELECT WORD FROM INFORMATION_SCHEMA.KEYWORDS WHERE RESERVED = 0;
The latter two queries are equivalent to:
SELECT WORD FROM INFORMATION_SCHEMA.KEYWORDS WHERE RESERVED;
SELECT WORD FROM INFORMATION_SCHEMA.KEYWORDS WHERE NOT RESERVED;
If you build MySQL from source, the build process generates a keyword_list.h
header file containing an array of keywords and their reserved status. This file can be found in the sql
directory under the build directory. This file may be useful for applications that require a static source for the keyword list.