CREATE [OR REPLACE] LIBRARY
Use the CREATE [OR REPLACE] LIBRARY command to create a user-defined shared library. After the library is added to the database, it is immediately available for use by a UDX.
You cannot change the library name by using this command. To change a library name, you must drop the library and create a library with the new name.
Synopsis
CREATE [OR REPLACE] LIBRARY library_name
[ AUTOMATIC LOAD | MANUAL LOAD ]
[NO DEPENDENCIES| DEPENDENCIES deplibs]
[ EXTERNAL HOST OBJECT 'host_object_filename' ]
[ EXTERNAL SPU OBJECT 'SPU_object_filename' ]
Inputs
| Input | Description |
|---|---|
| library name | The name of the library that you want to create or replace.
The name must be unique within the current database. You must be connected
to the database where the library is defined. You cannot change the
name by using the CREATE OR REPLACE LIBRARY command. For systems that support multiple schemas, you can specify a name in the format schema.library to create a library in a different schema of the current database. You cannot create a library in a different database. |
| [AUTOMATIC LOAD | MANUAL LOAD] | Automatic load specifies that the system automatically opens the library before any objects are used that depend on it. Manual load specifies that the UDX is responsible for opening and closing manual load libraries when they are needed. |
| DEPENDENCIES deplibs | Specifies an optional list of user-defined shared library dependencies for the UDX. You can specify one or a comma-separated list of library names. |
| NO DEPENDENCIES | Specifies that there are no dependencies for the UDX, which is the default if DEPENDENCIES deplibs is omitted. You can use this option to clear any previous dependencies that are declared for the UDX. |
| EXTERNAL HOST OBJECT 'host_object_filename' | Specifies the path name to the compiled host object file of the shared library. |
| EXTERNAL SPU OBJECT 'SPU_object_filename' | Specifies the path name to the compiled object file of the shared library for the Linux® SPU environment. Specify the spu10 compiled object for Rev10 SPUs on IBM® Netezza® 100 and Netezza 100 models. |
Outputs
| Output | Description |
|---|---|
| CREATE LIBRARY | The message that is returned if the command is successful. |
| ERROR: Object with name 'libname' already exists | The message that is returned if you use the CREATE LIBRARY command for a library name that exists. Use CREATE OR REPLACE or specify a unique library name. |
| ERROR: lookupLibrary: library libname does not exist | The message that the system returns if the specified shared library does not exist in the current database. |
| ERROR: Unable to calculate cksum for file filename | The message that is returned if the object file path name cannot be resolved to a file. |
Description
The user-defined shared library is created in the current database. You cannot replace a user-defined library that is in use in an active query. After the active query transaction completes, the Netezza Performance Server system processes the CREATE OR REPLACE LIBRARY command to replace the library.
Privileges required
You must be the database admin user, own the current database, or own the current schema on systems that support multiple schemas. Other users must have Create Library privilege to use the CREATE LIBRARY command. Also, if you use CREATE OR REPLACE LIBRARY to change a UDF, you must have Create Library and Alter privilege for the library to change it.
Common tasks
You can use the CREATE [OR REPLACE] LIBRARY command to create and become the owner of a new shared library. You must create the library and any of its dependencies and compile them by using nzudxcompile before you can use this command to register the shared library with the Netezza Performance Server system. The library is defined as an object in the current database.
Usage
- To create a sample library named mylib, enter:
MYDB.SCHEMA(MYUSER)=> CREATE LIBRARY mylib AUTOMATIC LOAD EXTERNAL HOST OBJECT '/home/nz/libs/mylib.o_x86' EXTERNAL SPU OBJECT '/home/nz/libs/mylib.o_spu10'; CREATE LIBRARY