Key Column Assignment Method

The collection metadata component that specifies the method used to assign keys to objects that are inserted into the collection.

Property Value
Default value UUID
Allowed values UUID, GUID, SEQUENCE, CLIENT, and EMBEDDED_OID
JSON collection metadata document path keyColumn.assignmentMethod

For descriptions of these methods, see Table 1.

Table 1 Key Assignment Methods

Method Description
UUID (default — but not used by Oracle Database API for MongoDB) Keys are generated by SODA, based on the UUID (a Universal Unique IDentifier).
GUID Keys are generated in Oracle Database by SQL function SYS_GUID, described in Oracle Database SQL Language Reference.
SEQUENCE Keys are generated in Oracle Database by a database sequence. If you specify the key assignment method as SEQUENCE then you must also specify the name of that sequence — see Key Column Sequence Name.
CLIENT

Keys are assigned by the client application.

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.

EMBEDDED_OID (used always by Oracle Database API for MongoDB)

This method is used only, and automatically, with Oracle Database API for MongoDB, which is available only for an Oracle Autonomous Database. (You cannot create a collection that uses this method with any of the SODA implementations/languages.)

The column value is a string (data type VARCHAR2). The value is also embedded in the documents of the collection, as the value of top-level field _id.

  • If a document already has a top-level field _id, then a string representation of that field value is used for the key column.

  • If a document has no such field, then a field _id with a generated value is embedded in the document at top level, and that value is used for the key column. The value is a string hexadecimal representation of a 12-byte binary OID (ObjectID).