18.3. The Namespace for Stored Routines


Each stored routine is associated with a particular database, just like a table or a view:

  • MySQL interprets an unqualified reference, routine_name, as a reference to a procedure or function in the default database. To refer to a routine in a specific database, use a qualified name of the form db_name.routine_name.

  • When the routine executes, it implicitly changes the default database to the database associated with the routine and restores the previous default database when it terminates. Due to this association of a routine with a database, you must have access to that database to be able to invoke the routine. (The means of access depends on the routine's security characteristic. See Section 18.5, "Creating Stored Routines.")

  • When you drop a database, any stored routines in the database are also dropped.

Stored procedures and functions do not share the same namespace. It is not possible to have two procedures or two functions with the same name in a database, but it is possible to have a procedure and a function with the same name in a database.



MySQL 5 Certification Study Guide
MySQL 5.0 Certification Study Guide
ISBN: 0672328127
EAN: 2147483647
Year: 2006
Pages: 312

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net