SODA Collection Metadata

It describes SODA Collection metadata on the database.

SODA Collection Metadata on Autonomous Database

Describes default and customized collection metadata on Autonomous Database.

SODA Default Collection Metadata on Autonomous Database

Describes the default collection metadata on Autonomous Database, that is the metadata for a collection that is added when custom metadata is not supplied.

Each SODA implementation provides a way to create a default collection when you supply a collection name. For example, in SODA for Java you use the createCollection method and supply just a collection name parameter:

db.admin().createCollection("myCol");

This creates a collection with default collection metadata. When you create a default collection on your database, the collection metadata includes the following information (regardless of which SODA implementation you use to create the default collection):

{
   "keyColumn" :
   {
      "name" : "ID",
      "sqlType" : "VARCHAR2",
      "maxLength" : 255,
      "assignmentMethod" : "UUID"
   },

   "contentColumn" :
   {
      "name" : "JSON_DOCUMENT",
      "sqlType" : "BLOB",
      "jsonFormat" : "OSON"
   },
   "versionColumn" :
   {
     "name" : "VERSION",
     "method" : "UUID"
   },
   
   "lastModifiedColumn" :
   {
     "name" : "LAST_MODIFIED"
   },
   
   "creationTimeColumn" :
   {
      "name" : "CREATED_ON"
   },
   
   "readOnly" : false
}
Note

Using Always Free Autonomous Database with Oracle Database 23ai, the default metadata changes as follows.
{
   "keyColumn" :
   {
      "name" : "ID",
      "sqlType" : "VARCHAR2",
      "maxLength" : 255,
      "assignmentMethod" : "UUID"
   },

   "contentColumn" :
   {
      "name" : "JSON_DOCUMENT",
      "sqlType" : "JSON",
   },
   "versionColumn" :
   {
     "name" : "VERSION",
     "method" : "UUID"
   },
   
   "lastModifiedColumn" :
   {
     "name" : "LAST_MODIFIED"
   },
   
   "creationTimeColumn" :
   {
      "name" : "CREATED_ON"
   },
   
   "readOnly" : false
}

SODA Customized Collection Metadata on Autonomous Database

Describes SODA collection custom metadata on Autonomous Database.

Each SODA implementation provides a way to customize the collection metadata during collection creation. For example, in SODA for Java, you can use the following command:

OracleDocument metadata = db.createDocumentFromString("metadata_string");
OracleCollection col = db.admin().createCollection("myCustomColl", metadata);

In this example, for metadata_string you can use the default metadata as the starting point, and customize the following:

  • Change keyColumn.assignmentMethod to CLIENT: Change the value of the assignmentMethod under keyColumn in the metadata to CLIENT (instead of UUID).

    Valid values for keyColumn.assignmentMethod on Autonomous Database:

    • UUID (default): Keys are generated by SODA, based on the UUID.

    • CLIENT: Keys are assigned by the client application.

  • Provide a mediaTypeColumn name value: A media type column is needed if the collection is to be heterogeneous, that is, it can store documents other than JavaScript Object Notation (JSON). See Media Type Column Name for details.

The following example specifies client-assigned keys and a custom media type column. The mediaTypeColumn name is specified with the value YOUR_MEDIA_TYPE_COLUMN_NAME. Otherwise, the default settings are used.

{
   "keyColumn" :
   {
      "name" : "ID",
      "sqlType" : "VARCHAR2",
      "maxLength" : 255,
      "assignmentMethod" : "CLIENT"
   },
   
   "contentColumn" :
   {
      "name" : "JSON_DOCUMENT",
      "sqlType" : "BLOB"
   },

   "versionColumn" :
   {
     "name" : "VERSION",
     "method" : "UUID"
   },

   "lastModifiedColumn" :
   {
     "name" : "LAST_MODIFIED"
   },

   "creationTimeColumn" :
   {
      "name" : "CREATED_ON"
   },

   "mediaTypeColumn" :
   {
      "name" : "YOUR_MEDIA_TYPE_COLUMN_NAME"
   },

   "readOnly" : false
}