9.6. Handling of reserved words in MySQL

Source: Internet
Author: User

Attempting to use a qualifier, such as using an embedded MySQL data type or function name as a table or column name, such as timestamp or group, can cause a common problem. Allows you to do this (for example, ABS can be used as a column name). However, by default, spaces are not allowed between the function name and the following ' (' character) in a number call. This requirement makes the function call different from the column name reference.

The disadvantage of this behavior is that omitting a space in some contexts causes the identifier to be interpreted as the function name. For example, the statement is valid:

mysql>CREATE TABLE Abs (Val INT);

However, omitting the space behind ABS causes a syntax error because the statement appears to call the ABS () function when omitted:

mysql>CREATE TABLE Abs (Val INT);

If the SQL Server pattern includes the Ignore_space mode value, the server allows the function to be called with a space between the function name and the following ' (' character). This causes the function name to be treated as a reserved word. As a result, identifiers that are the same as the function names must be caused by section 9.2, "Database, table, index, column, and alias". SQL Server mode is controlled as described in the 5.3.2 section, "SQL Server Mode".

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

In MySQL, the characters in the following table are explicitly reserved. Most of these digital binaries are used by standard SQL as column names and/or table names (for example, GROUP). A few are retained because MySQL needs them and (currently) uses the YACC parser. Reserved words can be used as identifiers when they are caused.

MySQL allows some of the keywords to be used as unrecognized identifiers, because many people have been using them before. Some examples are listed below:

    • ACTION

    • BIT

    • DATE

    • Enum

    • NO

    • TEXT

    • Time

    • TIMESTAMP

9.6. Handling of reserved words in MySQL

Related Article

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.