Hướng dẫn mysql database name rules
Certain objects within MySQL, including database, table, index, column, alias, view, stored procedure, partition, tablespace, resource group and other object names are known as identifiers. This section describes the permissible syntax for identifiers in MySQL. Section 9.2.1, “Identifier Length Limits”, indicates the maximum length of each type of identifier. Section 9.2.3, “Identifier Case Sensitivity”, describes which types of identifiers are case-sensitive and under what conditions. An identifier may be quoted or unquoted. If an identifier contains special characters or is a reserved word, you must quote it whenever you refer to it. (Exception: A reserved word that follows a period in a qualified name must be an identifier, so it need not be quoted.) Reserved words are listed at Section 9.3, “Keywords and Reserved Words”. Internally, identifiers are converted to and are stored as Unicode (UTF-8). The permissible Unicode characters in identifiers are those in the Basic Multilingual Plane (BMP). Supplementary characters are not permitted. Identifiers thus may contain these characters:
The identifier quote character is the backtick
(
If the
The Identifier quote characters can be included within an identifier if you quote the identifier. If the character to be included within the identifier is the same as that used to quote the identifier itself, then you need to double the character. The following statement creates a table named
In the select list of a query, a quoted column alias can be specified using identifier or string quoting characters:
Elsewhere in the statement, quoted references to the alias must use identifier quoting or the reference is treated as a string literal. It is recommended that you do not use names that begin with Be
careful when using It is also recommended that you do not use column names that begin with A user variable cannot be used directly in an SQL statement as an identifier or as part of an identifier. See Section 9.4, “User-Defined Variables”, for more information and examples of workarounds. Special characters in database and table names are encoded in the corresponding file system names as described in Section 9.2.4, “Mapping of Identifiers to File Names”. It is possible to run test cases against a production server. This is very unlikely to happen by accident, as mysql-test-run.pl will start its own server unless you use the
For examples of how to name objects, examine the existing test cases. Of course, you can name columns and other objects inside tables as you wish. |