Documentation Home
MySQL 9.3 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 40.8Mb
PDF (A4) - 40.9Mb
Man Pages (TGZ) - 261.1Kb
Man Pages (Zip) - 368.3Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb


15.7.7.10 SHOW CREATE LIBRARY Statement

SHOW CREATE LIBRARY [database_name.]library_name

Returns the text that can be used to re-create the named JavaScript library in the named database; the database defaults to the current database if one is not specified. SeeSection 15.1.17, “CREATE LIBRARY Statement”, for more information.

For an account other than the account which created the library, access to routine properties depends on the privileges granted to the account, as described here:

  • With theSHOW_ROUTINE privilege or the globalSELECT privilege, the account can see all library properties, including its definition. This means thatSHOW CREATE LIBRARY prints the source code of the library, and all libraries in the Information Schemalibraries table are visible to this account.

  • With theCREATE ROUTINE,ALTER ROUTINE, orEXECUTE privilege granted at a scope that includes the library, the account can see all routine properties except its definition. This means that the associated row inINFORMATION_SCHEMA.LIBRARIES is visible but,SHOW CREATE LIBRARY does not print the library's source code.

Library code may contain SQL statements (known as a JavaScript SQL callout). The statements are restricted, based on theINVOKER andDEFINER security contexts of the stored program using that library. Such SQL statements follow the usual restrictions applying to stored functions and stored procedures (seeSection 27.9, “Restrictions on Stored Programs”).

mysql> SHOW CREATE LIBRARY jslib.lib1\G*************************** 1. row ***************************       Library: lib1      sql_mode: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTIONCreate Library: CREATE LIBRARY `lib1`    LANGUAGE JAVASCRIPT COMMENT "This is lib1"AS $$      export function f(n) {        return n      }    $$1 row in set (0.00 sec)mysql> SHOW CREATE LIBRARY jslib.lib2\G*************************** 1. row ***************************       Library: lib2      sql_mode: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTIONCreate Library: CREATE LIBRARY `lib2`    LANGUAGE JAVASCRIPT COMMENT "This is lib2"AS $$      export function g(n) {        return n * 2      }    $$1 row in set (0.00 sec)

For further information and examples, seeSection 27.3.8, “Using JavaScript Libraries”.