Storing JSON documents

JSON and BSON data can be stored in columns, as long as the column data type being used is supported by the table.

Supported column data types include:
  • BLOB (row-organized tables only)
  • CHAR (row and column organized tables)
  • CLOB (row-organized tables only)
  • VARBINARY (row and column organized tables)
  • VARCHAR (row and column organized tables)

Like any other data value that is stored within Db2®, storing JSON or BSON data into a table is done by using an INSERT or UPDATE SQL statement. It is also done by using one of the available utilities, such as Load, Import, or Ingest.

If your JSON or BSON data is fairly large, then consider options that help to improve retrieval performance by using the Db2 buffer pool, such as:
  • Defining the table in a table space with a larger page size, when using a non-LOB data type for the column. Defining the table this way accommodates a larger row size (as needed).
  • Using the INLINE LENGTH option for the column definition, when using a LOB data type for the column. Using the INLINE LENGTH option enables smaller documents to be treated efficiently.