Reserved Words
758
It is possible to create a stored function with the same name as a built-in function, but to invoke the
stored function it is necessary to qualify it with a database name. For example, if you create a stored
function named
PI
in the
test
database, you invoke it as
test.PI()
because the server resolves
PI()
[911]
as a reference to the built-in function.
• User-defined functions and stored functions
User-defined functions and stored functions share the same namespace, so you cannot create a
UDF and a stored function with the same name.
The preceding function name resolution rules have implications for upgrading to versions of MySQL
that implement new built-in functions:
• If you have already created a user-defined function with a given name and upgrade MySQL to a
version that implements a new built-in function with the same name, the UDF becomes inaccessible.
To correct this, use
DROP FUNCTION
to drop the UDF, and then use
CREATE FUNCTION
to re-
create the UDF with a different nonconflicting name.
• If a new version of MySQL implements a built-in function with the same name as an existing stored
function, you have two choices: Rename the stored function to use a nonconflicting name, or change
calls to the function so that they use a schema qualifier (that is, use
schema_name.func_name()
syntax).
9.3. Reserved Words
Certain words such as
SELECT
,
DELETE
, or
BIGINT
are reserved and require special treatment for
use as identifiers such as table and column names. This may also be true for the names of built-in
functions.
Reserved words are permitted as identifiers if you quote them as described in
Section 9.2, “Schema
Object Names”
:
mysql>
CREATE TABLE interval (begin INT, end INT);
ERROR 1064 (42000): You have an error in your SQL syntax ...
near 'interval (begin INT, end INT)'
mysql>
CREATE TABLE `interval` (begin INT, end INT);
Query OK, 0 rows affected (0.01 sec)
Exception: A word that follows a period in a qualified name must be an identifier, so it need not be
quoted even if it is reserved:
mysql>
CREATE TABLE mydb.interval (begin INT, end INT);
Query OK, 0 rows affected (0.01 sec)
Names of built-in functions are permitted as identifiers but may require care to be used as such. For
example,
COUNT
is acceptable as a column name. However, by default, no whitespace is permitted
in function invocations between the function name and the following “
(
” character. This requirement
enables the parser to distinguish whether the name is used in a function call or in nonfunction context.
For further detail on recognition of function names, see
Section 9.2.3, “Function Name Parsing and
Resolution”
.
The words in the following table are explicitly reserved in MySQL 5.0. At some point, you might
upgrade to a higher version, so it is a good idea to have a look at future reserved words, too. You
can find these in the manuals that cover higher versions of MySQL. Most of the words in the table
are forbidden by standard SQL as column or table names (for example,
GROUP
). A few are reserved
because MySQL needs them and uses a
yacc
parser. A reserved word can be used as an identifier if
you quote it.
For a more detailed list of reserved words, including differences between versions, see
Reserved
Words in MySQL 5.0
.
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...