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
.
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 ...