Enabling Db2 JSON
To enable JSON functionality, you must configure the Db2 database and the database server.
Before you begin
- Update the PATH system variable for Java™.
- Add the db2jcc4.jar file to the CLASSPATH environment variable or the -cp command-line switch.
- If you do not have a UTF-8 database with a 32 KB page size that
you can use, create one. For example, to create a database jsondb with
automatic storage and territory us, enter the following
command:
Make a note of the database server host name, IP address, port number, and database name. This information is required for client configuration.db2 create database jsondb automatic storage yes using codeset utf-8 territory us pagesize 32 K
- Although not recommended, if you are using a database with less
than 32 K pagesize, manually create a temporary table space with 32
K pagesize. For example, enter the following command:
CREATE BUFFERPOOL NOSQLSYSTOOLSBP ALL DBPARTITIONNUMS SIZE AUTOMATIC PAGESIZE 32K CREATE TEMPORARY TABLESPACE NOSQLSYSTOOLSTEMP PAGESIZE 32K MANAGED BY AUTOMATIC STORAGE BUFFERPOOL NOSQLSYSTOOLSBP
- Ensure that you have proper authority to create tables and functions
that are required to enable NoSQL JSON functionality. You require
the following privileges:
- CREATETAB authority and CREATE FUNCTION for the SYSTOOLS schema
- DBADM authority for the target database
- Ensure that the dft_table_org database configuration parameter is set to ROW.
- Ensure that you have the database server host name, IP address, port number, and database name handy from the server configuration.
Procedure
To configure a Db2 database for JSON functionality:
Example
The
following sample script shows the commands to enable Db2 JSON:
./db2nosql.sh -user myuser -hostName myhost -port 50000 -db jsondb -password mypasswd -setup enable
Database artifacts created successfully
nosql>quit