5 Collection Specifications
A collection specification is a JSON object that provides information about the Oracle Database table or view underlying a collection object. The table or view is created when you create the collection.
Note:
In collection specifications, you must use strict JSON syntax. That is, you must enclose each nonnumeric value in double quotation marks.
When you create a collection using PUT
collection you can set custom metadata for it by providing a collection specification for it as the request body.
Collection metadata for an existing collection can be returned as part of a GET
catalog operation.
Example 5-1 shows the collection specification that specifies the default collection metadata.
Table 5-1 describes the collection specification fields and their possible values.
Note:
If you omit one of the optional columns (created-on timestamp, last-modified timestamp, version, or media type) from the collection specification then no such column is created. At a minimum, a collection has a key column and a content column.
Table 5-1 Collection Specification Fields
Field | Description | Possible Values |
---|---|---|
|
SQL name of database schema (user account) that owns table or view underlying collection object. |
— |
|
SQL name of table or view underlying collection object. |
— |
|
Name of key column. |
Default: |
|
SQL data type of key column. |
|
|
Maximum length of key column, if not of |
Default: 255 |
|
Key assignment method. |
|
|
If |
Name of existing database sequence |
|
Name of content column. |
Default: |
|
SQL data type of content column. |
|
|
Maximum length of content column, if not of LOB data type. |
The default length is 4000 bytes. If |
|
Validation level of content column. Corresponds to SQL condition
Some of the relaxations that
|
|
|
Compression level for SecureFiles stored in content column. |
|
|
Caching of SecureFiles stored in content column. |
|
|
Encryption algorithm for SecureFiles stored in content column.Foot 1 |
|
|
Name of optional created-on timestamp column. This column has SQL data type |
Default: |
|
Name of optional last-modified timestamp column. This column has SQL data type |
Default: |
|
Name of nonunique index on timestamp column. The index is created if a name is specified. |
|
|
Name of optional version (ETag) column. This column has SQL data type Note: If the method is |
Default: |
|
Versioning method. |
|
|
Name of optional object media type column. This column has SQL data type |
|
|
Read/write policy: |
|
Footnote 1
Set up Encryption Wallet before creating a collection with SecureFile encryption. For information about the SET
ENCRYPTION
WALLET
clause of the ALTER
SYSTEM
statement, see Oracle Database SQL Language Reference.
Example 5-1 Default Collection Metadata
{
"schemaName" : "mySchemaName",
"tableName" : "myTableName",
"keyColumn" :
{
"name" : "ID",
"sqlType" : "VARCHAR2",
"maxLength" : 255,
"assignmentMethod" : "UUID"
},
"contentColumn" :
{
"name" : "JSON_DOCUMENT",
"sqlType" : "BLOB",
"compress" : "NONE",
"cache" : true,
"encrypt" : "NONE",
"validation" : "STANDARD"
},
"versionColumn" :
{
"name" : "VERSION",
"method" : "SHA256"
},
"lastModifiedColumn" :
{
"name" : "LAST_MODIFIED"
},
"creationTimeColumn" :
{
"name" : "CREATED_ON"
},
"readOnly" : false
}
See Also:
-
Oracle Database JSON Developer’s Guide for information about the syntax possibilities used by SQL condition
is json
-
http://tools.ietf.org/html/rfc4627
for the JSON RFC 4627 standard -
Oracle Database SecureFiles and Large Objects Developer's Guide for information about SecureFiles LOB storage
- Key Assignment Method
The key assignment method determines how keys are assigned to objects that are inserted into a collection. - Versioning Method
The versioning method determines how the REST server computes version values for objects when they are inserted into a collection or replaced.
Related Topics
5.1 Key Assignment Method
The key assignment method determines how keys are assigned to objects that are inserted into a collection.
Table 5-2 Key Assignment Methods
Method | Description |
---|---|
|
Keys are integers generated by a database sequence. You must specify the name of the sequence in the |
|
Keys are generated by the SQL function |
|
Keys are generated by the built-in |
|
Keys are assigned by the client application (not recommended). |
Oracle REST standards strongly recommend using server-assigned keys; that is, avoiding the key assignment method CLIENT
. If you need simple numeric keys, Oracle recommends SEQUENCE
. If any unique identifier is sufficient, Oracle recommends UUID
.
If the key assignment method is SEQUENCE
, GUID
, or UUID
, you insert a object into the collection with operation POST object. The REST server always interprets POST
as an insert operation, assigning a key and returning the key in the response body.
If the key assignment method is CLIENT
, you cannot use POST
to a insert a object in the collection, because the URL path does not include the necessary key. Instead, you must insert the object into the collection using PUT object. If the object is not already in the collection, then the REST server interprets PUT
as an insert operation. If the object is already in the collection, then the REST server interprets PUT
as a replace operation. PUT
is effectively equivalent to the SQL statement MERGE
.
Caution:
If client-assigned keys are used and the key column type is VARCHAR2
then Oracle recommends that the database character set be AL32UTF8. This ensures that conversion of the keys to the database character set is lossless.
Otherwise, if client-assigned keys contain characters that are not supported in your database character set then conversion of the key into the database character set during a read or write operation is lossy. This can lead to duplicate-key errors during insert operations. More generally, it can lead to unpredictable results. For example, a read operation could return a value that is associated with a different key from the one you expect.
Related Topics
Parent topic: Collection Specifications
5.2 Versioning Method
The versioning method determines how the REST server computes version values for objects when they are inserted into a collection or replaced.
Table 5-3 Versioning Methods
Method | Description |
---|---|
|
The REST server computes an MD5 checksum on the bytes of object content. For bytes with character data types (such as For a bulk insert, the request body is parsed as an array of objects and the bytes of the individual objects are re-serialized with UTF-8 encoding, regardless of the encoding chosen for storage. In all cases, the checksum is computed on the bytes as they would be returned by a |
|
The REST server computes a SHA256 checksum on the bytes of object content. For bytes with character data types (such as For a bulk insert, the request body is parsed as an array of objects and the bytes of the individual objects are re-serialized with UTF-8 encoding, regardless of the encoding chosen for storage. In all cases, the checksum is computed on the bytes as they would be returned by a |
|
Ignoring object content, the REST server generates a universally unique identifier (UUID)—a 32-character hexadecimal value—when the object is inserted and for every replace operation (even if the replace operation does not change the object content). |
|
Ignoring object content, the REST server generates an integer value, derived from the value returned by the SQL |
|
Ignoring object content, the REST server assigns version 1 when the object is inserted and increments the version value every time the object is replaced. |
|
The REST server does not assign version values during insert and replace operations. During GET operations, any non-null value stored in the version column is used as an ETag. Your application is responsible for populating the version column (using, for example, a PL/SQL trigger or asynchronous program). |
MD5
and SHA256
compute checksum values that change when the content itself changes, providing a very accurate way to invalidate client caches. However, they are costly, because the REST server must perform a byte-by-byte computation over the objects as they are inserted or replaced.
UUID
is most efficient for input operations, because the REST server does not have to examine every byte of input or wait for SQL to return function values. However, replacement operations invalidate cached copies even if they do not change object content.
TIMESTAMP
is useful when you need integer values or must compare two versions to determine which is more recent. As with UUID
, replacement operations can invalidate cached copies without changing object content. Because the accuracy of the system clock may be limited, TIMESTAMP
is not recommended if objects can change at very high frequency (many times per millisecond).
SEQUENTIAL
is also useful when you need integer values or must compare two versions to determine which is more recent. Version values are easily understood by human users, and the version increases despite system clock limitations. However, the increment operation occurs within SQL; therefore, the new version value is not always available to be returned in the REST response body.
Parent topic: Collection Specifications