Processing of Reserved Words in MySQL

Source: Internet
Author: User
9.6.MySQL tries to use an identifier for processing reserved words. For example, using an embedded MySQL DATA type or function name as a table name or column name, such as TIMESTAMP or GROUP may cause a common problem. This operation is allowed (for example, ABS can be used as a column name ). However, by default (

9.6.MySQL tries to use an identifier for processing reserved words. For example, using an embedded MySQL DATA type or function name as a table name or column name, such as TIMESTAMP or GROUP may cause a common problem. This operation is allowed (for example, ABS can be used as a column name ). However, by default (

9.6. Processing of Reserved Words in MySQL

Try to use an identifier, such as using the embedded MySQL DATA type or function name as the table name or column name, such as TIMESTAMP or GROUP, which may cause a common problem. This operation is allowed (for example, ABS can be used as a column name ). However, by default, spaces are not allowed between the '(') at the end of the function name in a number call. This requirement makes the function call different from the column name reference.

The negative result of this behavior is that a space is omitted in some contexts and the identifier is interpreted as the function name. For example, the statement is valid:

mysql> CREATE TABLE abs (val INT);

However, omitting spaces after abs may cause syntax errors, because the statement seems to call the ABS () function:

mysql> CREATE TABLE abs(val INT);

If the SQL Server mode includes the IGNORE_SPACE mode value, the server allows space between the function name and. In this way, the function name is considered as a reserved word. The result is that the identifiers with the same function name must follow the description in section 9.2, "database, table, index, column, and alias. The SQL Server mode is controlled as described in section 5.3.2 and "SQL SERVER mode.

The word after the period in a qualified name must be an identifier, so it does not need to be caused, even if it is a reserved word.

In MySQL, the words in the following table are explicitly reserved. Most numeric statements are used as column names and/or table names (for example, GROUP) by standard SQL statements ). A few are retained because MySQL needs them (currently ).YaccParser. Reserved Words can be used as identifiers after being caused.

ADD ALL ALTER
ANALYZE AND AS
ASC ASENSITIVE BEFORE
BETWEEN BIGINT BINARY
BLOB BOTH BY
CALL CASCADE CASE
CHANGE CHAR CHARACTER
CHECK COLLATE COLUMN
CONDITION CONNECTION CONSTRAINT
CONTINUE CONVERT CREATE
CROSS CURRENT_DATE CURRENT_TIME
CURRENT_TIMESTAMP CURRENT_USER CURSOR
DATABASE DATABASES DAY_HOUR
DAY_MICROSECOND DAY_MINUTE DAY_SECOND
DEC DECIMAL DECLARE
DEFAULT DELAYED DELETE
DESC DESCRIBE DETERMINISTIC
DISTINCT DISTINCTROW DIV
DOUBLE DROP DUAL
EACH ELSE ELSEIF
ENCLOSED ESCAPED EXISTS
EXIT EXPLAIN FALSE
FETCH FLOAT FLOAT4
FLOAT8 FOR FORCE
FOREIGN FROM FULLTEXT
GOTO GRANT GROUP
HAVING HIGH_PRIORITY HOUR_MICROSECOND
HOUR_MINUTE HOUR_SECOND IF
IGNORE IN INDEX
INFILE INNER INOUT
INSENSITIVE INSERT INT
INT1 INT2 INT3
INT4 INT8 INTEGER
INTERVAL INTO IS
ITERATE JOIN KEY
KEYS KILL LABEL
LEADING LEAVE LEFT
LIKE LIMIT LINEAR
LINES LOAD LOCALTIME
LOCALTIMESTAMP LOCK LONG
LONGBLOB LONGTEXT LOOP
LOW_PRIORITY MATCH MEDIUMBLOB
MEDIUMINT MEDIUMTEXT MIDDLEINT
MINUTE_MICROSECOND MINUTE_SECOND MOD
MODIFIES NATURAL NOT
NO_WRITE_TO_BINLOG NULL NUMERIC
ON OPTIMIZE OPTION
OPTIONALLY OR ORDER
OUT OUTER OUTFILE
PRECISION PRIMARY PROCEDURE
PURGE RAID0 RANGE
READ READS REAL
REFERENCES REGEXP RELEASE
RENAME REPEAT REPLACE
REQUIRE RESTRICT RETURN
REVOKE RIGHT RLIKE
SCHEMA SCHEMAS SECOND_MICROSECOND
SELECT SENSITIVE SEPARATOR
SET SHOW SMALLINT
SPATIAL Specpacific SQL
SQLEXCEPTION SQLSTATE SQLWARNING
SQL _BIG_RESULT SQL _CALC_FOUND_ROWS SQL _SMALL_RESULT
SSL STARTING STRAIGHT_JOIN
TABLE TERMINATED THEN
TINYBLOB TINYINT TINYTEXT
TO TRAILING TRIGGER
TRUE UNDO UNION
UNIQUE UNLOCK UNSIGNED
UPDATE USAGE USE
USING UTC_DATE UTC_TIME
UTC_TIMESTAMP VALUES VARBINARY
VARCHAR VARCHARACTER VARYING
WHEN WHERE WHILE
WITH WRITE X509
XOR YEAR_MONTH ZEROFILL

MySQL allows some keywords to be used as unprovoked identifiers, because many people have used them before. Some examples are listed below:

  • ACTION

  • BIT

  • DATE

  • ENUM

  • NO

  • TEXT

  • TIME

  • TIMESTAMP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.