Identifier Qualifiers
753
The following table describes the maximum length for each type of identifier.
Identifier
Maximum Length (characters)
Database
64
Table
64
Column
64
Index
64
Constraint
64
Stored Procedure or Function
64
Trigger
64
View
64
Alias
256 (see exception following table)
Compound Statement Label
16
As of MySQL 5.0.52, aliases for column names in
CREATE VIEW
statements are checked against the
maximum column length of 64 characters (not the maximum alias length of 256 characters).
Identifiers are stored using Unicode (UTF-8). This applies to identifiers in table definitions that are
stored in
.frm
files and to identifiers stored in the grant tables in the
mysql
database. The sizes of
the identifier string columns in the grant tables are measured in characters. You can use multi-byte
characters without reducing the number of characters permitted for values stored in these columns,
something not true prior to MySQL 4.1. As indicated earlier, the permissible Unicode characters are
those in the Basic Multilingual Plane (BMP). Supplementary characters are not permitted.
9.2.1. Identifier Qualifiers
MySQL permits names that consist of a single identifier or multiple identifiers. The components of a
multiple-part name must be separated by period (“
.
”) characters. The initial parts of a multiple-part
name act as qualifiers that affect the context within which the final identifier is interpreted.
In MySQL, you can refer to a table column using any of the following forms.
Column Reference
Meaning
col_name
The column
col_name
from whichever table used in the statement
contains a column of that name.
tbl_name.col_name
The column
col_name
from table
tbl_name
of the default database.
db_name.tbl_name.col_name
The column
col_name
from table
tbl_name
of the database
db_name
.
The qualifier character is a separate token and need not be contiguous with the associated identifiers.
For example,
tbl_name.col_name
and
tbl_name . col_name
are equivalent.
If any components of a multiple-part name require quoting, quote them individually rather than quoting
the name as a whole. For example, write
`my-table`.`my-column`
, not
`my-table.my-
column`
.
A reserved word that follows a period in a qualified name must be an identifier, so in that context it
need not be quoted.
You need not specify a
tbl_name
or
db_name.tbl_name
prefix for a column reference in a
statement unless the reference would be ambiguous. Suppose that tables
t1
and
t2
each contain
a column
c
, and you retrieve
c
in a
SELECT
statement that uses both
t1
and
t2
. In this case,
c
is
ambiguous because it is not unique among the tables used in the statement. You must qualify it with a
table name as
t1.c
or
t2.c
to indicate which table you mean. Similarly, to retrieve from a table
t
in
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...