Skip to content

NoSQL Database

OCI NoSQL Database Cloud Service, API version 20190828. Tables are created from DDL statements, rows are written and read one at a time by primary key, and a SELECT subset of the NoSQL SQL dialect queries them. Everything runs in process on port 4599.

Supported operations

Area Operations
Tables CreateTable, GetTable, ListTables, UpdateTable, DeleteTable, ChangeTableCompartment, ListTableUsage
Indexes CreateIndex, GetIndex, ListIndexes, DeleteIndex
Rows UpdateRow (put), GetRow, DeleteRow
Query Query, PrepareStatement, SummarizeStatement
Work requests GetWorkRequest, ListWorkRequests, ListWorkRequestErrors, ListWorkRequestLogs, DeleteWorkRequest

The same port also serves the native driver protocol (POST /V2/nosql/data) that the Oracle NoSQL drivers speak. The Java driver (oracle.nosql.driver) is the one tested; the Go, Python and Node drivers use the same protocol but have not been run against floci-oci. See Native driver protocol. Both share one table and row store, so a row written through the driver reads back through the REST API and the other way round.

Not served: replicas (/tables/{t}/replicas) and /configuration with its KMS key actions.

Wire notes

  • Table and index mutations are work-request driven: 202, an opc-work-request-id header and no body. The work request is already SUCCEEDED with timeFinished set, and its one resource is entityType: TABLE, actionType CREATED, UPDATED or DELETED, and identifier the table OCID. Terraform's oci_nosql_table and oci_nosql_index wait on exactly that resource.
  • The work request operationType enum has only CREATE_TABLE, UPDATE_TABLE, DELETE_TABLE and UPDATE_CONFIGURATION, so CreateIndex, DeleteIndex and ChangeTableCompartment all report UPDATE_TABLE.
  • {tableNameOrId} is the table OCID, or the table name together with compartmentId. A name without compartmentId is 400 MissingParameter. Table names match case-insensitively.
  • ddlStatement is echoed verbatim: GetTable returns the last DDL statement the table received, the CREATE TABLE or the latest ALTER TABLE. Terraform reads it back and compares it, ignoring case only.
  • A deleted table stays readable by OCID as a DELETED tombstone. A name lookup, a write or a query no longer finds it, and the name can be reused. ListTables omits DELETED tables unless lifecycleState=DELETED or ALL asks for them.
  • Lists are wrapped ({"items":[…]}) and paginate with limit, page and opc-next-page. TableCollection also carries autoReclaimableTables, onDemandCapacityTables and an empty availableReplicationRegions.
  • Condition failures are results, not errors. An UpdateRow whose option (IF_ABSENT, IF_PRESENT) or if-match version does not hold is a 200 without version; with isGetReturnRow it carries existingVersion and existingValue. A DeleteRow that finds no row, or whose if-match does not match, is a 200 with isSuccess: false.
  • GetRow and DeleteRow take key as a repeated query parameter, one column:value per primary key column: ?key=tenant:acme&key=id:1.
  • etag on UpdateRow and GetRow is the row version.
  • Query takes limit/page and returns {"items":[…], "usage":{…}} with opc-next-page; without limit a page holds 100 results.

DDL subset

CREATE TABLE [IF NOT EXISTS] name (
    column type [GENERATED ALWAYS AS IDENTITY | GENERATED BY DEFAULT [ON NULL] AS IDENTITY [(START WITH n INCREMENT BY m)]]
                [NOT NULL] [DEFAULT literal] [COMMENT "text"],
    ...,
    PRIMARY KEY ([SHARD(column, ...),] column, ...)
) [USING TTL n DAYS|HOURS]

ALTER TABLE name (ADD column type ..., DROP column, ...)
ALTER TABLE name USING TTL n DAYS|HOURS
CREATE INDEX [IF NOT EXISTS] name ON table (column[.json.path] [AS type], ...)
DROP TABLE [IF EXISTS] name
DROP INDEX [IF EXISTS] name ON table

Types: INTEGER, LONG, FLOAT, DOUBLE, NUMBER, STRING (with AS UUID [GENERATED BY DEFAULT]), BOOLEAN, BINARY[(n)], TIMESTAMP[(p)], ENUM(...), ARRAY(type), MAP(type), RECORD(field type, ...) and JSON. Without SHARD(...) the shard key is the whole primary key. As Oracle's reference says, a trailing semicolon is an error, and a NOT NULL column needs a DEFAULT. CreateTable takes only CREATE TABLE and UpdateTable only ALTER TABLE. CREATE INDEX and the DROP statements are understood by SummarizeStatement; use the CreateIndex, DeleteIndex and DeleteTable operations to run them. A DDL syntax error is 400 InvalidParameter, and SummarizeStatement reports it as syntaxError.

Rows

  • UpdateRow checks each value against its column type and fills GENERATED identity and UUID columns; generatedValue returns the generated value. Giving a value for a GENERATED ALWAYS identity column is 400 InvalidParameter.
  • Fields that are not columns are ignored, and missing columns take their DEFAULT or null, unless isExactMatch is true, which makes either a 400.
  • ttl (days) sets the row's expiry; 0 means never. Without it, a new row takes the table's default TTL and an existing row keeps its expiry, unless isTtlUseTableDefault is set. GetRow reports timeOfExpiration. Expired rows are hidden at once and deleted by a sweep every ttl-sweep-interval-seconds.
  • A row written before an ALTER TABLE reads back in the current schema: a dropped column is gone and an added one shows its default.

SQL subset

[DECLARE $var TYPE; ...]
SELECT * | expr [AS name], ... FROM table [[AS] alias]
  [WHERE condition]
  [ORDER BY expr [ASC|DESC] [NULLS FIRST|LAST], ...]
  [LIMIT n] [OFFSET n]
  • Conditions: =, !=, <>, <, <=, >, >=, AND, OR, NOT, IS [NOT] NULL, EXISTS, [NOT] IN (...), [NOT] BETWEEN a AND b.
  • Expressions: string, number and boolean literals, NULL, $variables, dotted JSON paths ($u.info.address.city, u.info.city or info.city), + - * /, and the aggregates count(*), count, min, max, sum and avg.
  • Variables come from QueryDetails variables, keyed with or without $. A declared variable with no value is 400.
  • isPrepared: true takes the statement PrepareStatement returned.
  • Without ORDER BY, rows come back in primary key order.
  • Not supported, 400 InvalidParameter: UPDATE, INSERT, UPSERT and DELETE statements, GROUP BY, functions other than the five aggregates, and mixing aggregates with plain expressions.

Native driver protocol

POST /V2/nosql/data speaks serial version 4 of the driver protocol: the body is a 2-byte serial version and an NSON (binary, self-describing) map of a header and a payload, and the response is an NSON map. Field names, op codes and error codes follow the Java driver's NsonProtocol and BinaryProtocol (nosql-java-sdk 5.4.25), cross-checked against the Go driver. Version 4 is every current driver's default. A request with any other serial version gets the reply a pre-V4 server gives (the error byte UNSUPPORTED_PROTOCOL), so an old driver stepping down from V4 to V3 and V2 ends with UnsupportedProtocolException: the V3 binary protocol is not served.

Driver operation Op code Notes
tableRequest TABLE_REQUEST CREATE TABLE, ALTER TABLE, DROP TABLE, CREATE INDEX, DROP INDEX; a table name with only limits or tags updates them
getTable GET_TABLE
listTables LIST_TABLES names in alphabetical order, with startIndex and limit
getIndexes GET_INDEXES
get GET
put PUT, PUT_IF_ABSENT, PUT_IF_PRESENT, PUT_IF_VERSION TTL in days or hours, setUseTableDefaultTTL, setExactMatch, setReturnRow
delete DELETE, DELETE_IF_VERSION
prepare, query, queryIterable PREPARE, QUERY the SELECT subset below, with bound $variables and setLimit paging
writeMultiple WRITE_MULTIPLE puts and deletes on one shard key, atomic, see below
multiDelete MULTI_DELETE partial primary key, optional FieldRange, setMaxWriteKB with a continuation key
getTableUsage GET_TABLE_USAGE zero usage records, one per minute, see below

Any other operation (system requests, replicas) is error OPERATION_NOT_SUPPORTED, which the driver raises as OperationNotSupportedException.

  • writeMultiple runs its operations in order on one table, each seeing the ones before it. Every operation must address the same shard key (the SHARD(...) columns, or the whole primary key when the DDL names none); another shard key, or a second table, is ILLEGAL_ARGUMENT. More than 50 operations is BATCH_OP_NUMBER_LIMIT_EXCEEDED (BatchOperationNumberLimitException), the limit BinaryProtocol.BATCH_OP_NUMBER_LIMIT states. When an operation added with abortIfUnsuccessful fails (a put condition or match version that does not hold, a delete of a missing row or a stale version), every row the batch already wrote is put back and the result is getSuccess() == false with getFailedOperationIndex() and that operation's result, its existing row and version when it asked for them. A failing operation without the flag is reported in the results and the batch goes on. An invalid operation (a bad value, a missing key column) fails the whole request before anything is written.
  • multiDelete takes a key that names the leading primary key columns, the whole shard key included, and an optional FieldRange on the next primary key column; anything else is ILLEGAL_ARGUMENT. Rows are deleted in primary key order.
  • getTableUsage returns the latest completed minute when no time range is given, otherwise one record per completed minute from the start time to the end time (or now), paged with setLimit and setStartIndex; getLastReturnedIndex() is the index to continue from.

  • Endpoint: new NoSQLHandleConfig("http://localhost:4599").

  • Authorization: a cloudsim-style unsigned client (new StoreAccessTokenProvider()) works in the default tenancy's root compartment. A SignatureProvider signs each request as any OCI client does; the signature is handled like every other floci-oci request (floci-oci.auth.*), and the request works in its tenancy.
  • Compartment: the x-nosql-compartment-id header, which SignatureProvider sends from the request's compartment, NoSQLHandleConfig.setDefaultCompartment, or else the tenancy OCID. Only compartment OCIDs are understood, not compartment names. An unknown compartment is error RESOURCE_NOT_FOUND (ResourceNotFoundException).
  • Errors are HTTP 200 with an NSON body of error code and message, as the drivers expect: a missing table is TABLE_NOT_FOUND, an existing one TABLE_EXISTS, an index INDEX_NOT_FOUND or INDEX_EXISTS, an etag mismatch ETAG_MISMATCH, any other rejection ILLEGAL_ARGUMENT (IllegalArgumentException in Java) with the same message the REST API gives. A body that is not valid NSON is BAD_PROTOCOL_MESSAGE.
  • Every response echoes x-nosql-request-id; the Java driver discards a response without it.
  • Table operations finish at once: tableRequest returns ACTIVE (or DROPPED), so waitForCompletion returns without polling.
  • Values keep their column types: an INTEGER column reads back as an integer, LONG as a long, NUMBER as a number, TIMESTAMP as a timestamp, BINARY as bytes, and a JSON null inside a JSON column as JSON null. The REST API sees the same row with a TIMESTAMP as an ISO 8601 string and a BINARY as base64.
  • Row versions are the same counters the REST API reports, as bytes; a Version from the driver matches the REST etag of the same write.

Quickstart

E="--endpoint http://localhost:4599"
TENANCY=ocid1.tenancy.oc1..flocilocaltenancy0000000000000000000000000000000000000000

oci nosql table create $E --compartment-id "$TENANCY" --name users \
  --ddl-statement "CREATE TABLE users (id INTEGER, name STRING, info JSON, PRIMARY KEY (id))" \
  --wait-for-state SUCCEEDED
oci nosql row update $E --table-name-or-id users --compartment-id "$TENANCY" \
  --value '{"id": 1, "name": "ana", "info": {"city": "Lima"}}' --force
oci nosql row get $E --table-name-or-id users --compartment-id "$TENANCY" --key id:1
oci nosql query execute $E --compartment-id "$TENANCY" \
  --statement "SELECT name FROM users u WHERE u.info.city = 'Lima'"

Inferred behavior

These points are not stated by the OCI SDK models, the CLI or the Terraform provider under local/oracle, nor by the snapshotted Oracle documentation. They are floci-oci's best reading and may differ from the real service:

  • GetRow of a missing row is a 200 with no value and no etag.
  • The table OCID type is ocid1.nosqltable.
  • A table created without tableLimits is ON_DEMAND with 25 GB of storage and zero read and write units (the SDK model states that ON_DEMAND tables report zero units).
  • A CREATE TABLE for a name that already exists is 409 NotAuthorizedOrResourceAlreadyExists, or, with IF NOT EXISTS, a succeeded work request naming the existing table. A duplicate index name is the same 409.
  • ddlStatement after an ALTER TABLE is the ALTER statement, not a regenerated CREATE.
  • An ALTER TABLE that drops a column removes that column's values from every row, without changing the row versions. A column added later under the same name reads as its DEFAULT (or null) in the existing rows.
  • Column type is the upper-case DDL spelling (INTEGER, TIMESTAMP(3), ARRAY(STRING)); a UUID column is STRING with isAsUuid. Oracle's reference writes type names in upper case, but no source shows the REST field.
  • An ENUM value must match one of the declared symbols exactly, case included. A RECORD value names its fields case-insensitively, may not name a field the type does not declare, and is stored with every declared field, an absent one as null.
  • schema.ttl for an hour-based TTL is rounded up to whole days.
  • Row versions are opaque base64 counters, and the row etag equals the version.
  • usage units are nominal: one read or write unit per row operation, and one read unit per row scanned by a query.
  • ListTables sorts by timeCreated descending by default; ListIndexes by name ascending.
  • A row TTL is counted from the write, without rounding to an hour or day boundary.
  • Query semantics follow the Oracle NoSQL SQL reference, which is not in the local corpus: comparisons with SQL NULL or a missing field are unknown, so the row is filtered out; values of different types are never equal; ORDER BY sorts numbers before strings before booleans, with nulls last ascending and first descending; an unnamed SELECT expression is named after its last path step, or Column_<n>.
  • Query arithmetic is exact. Integer operands give INTEGER or LONG, and a sum, difference, product or negation outside the LONG range widens to NUMBER instead of wrapping; SUM over integers does the same. A FLOAT or DOUBLE operand gives a DOUBLE, and a NUMBER operand with integer or NUMBER operands gives a NUMBER. Division always gives a DOUBLE.
  • DeleteWorkRequest on a finished work request is 409 Conflict. Every emulated work request is finished, so a cancel always reports that.
  • A PrepareStatement result is the statement text, base64-encoded; queryPlan is not returned.
  • A table name in a query that does not exist is 404 NotAuthorizedOrNotFound.

Driver protocol points no source in the local corpus states:

  • Every query is answered as a "simple" query: no driver query plan is returned, so the server evaluates ORDER BY, LIMIT, OFFSET and aggregates itself and the driver only pages. The prepared statement is opaque bytes only floci-oci reads back. PreparedStatement.getQueryPlan() and getQuerySchema() are null.
  • Query pages are taken by setLimit alone; setMaxReadKB and setMaxMemoryConsumption are ignored, and a query without a limit returns every result in one batch. Each page re-evaluates the statement, so writes between pages can shift results.
  • TableResult.getSchema() is null: the JSON schema the real service returns is not reproduced. getDdl() returns the last DDL statement, as the REST ddlStatement does.
  • Consumed capacity is nominal: one read unit and kilobyte per row read, one write kilobyte per row written. Throttling and size limits are never raised.
  • A table created through the driver without limits is ON_DEMAND, as through the REST API.
  • Positional ? bind variables, the on-premises namespace header and ns:table names, and the lastWriteMetadata row metadata are not supported.
  • multiDelete counts one write kilobyte per deleted row against setMaxWriteKB, which is capped at 2048 (BinaryProtocol.WRITE_KB_LIMIT, also the default when it is 0). The continuation key is an opaque marker: the next call deletes whatever still matches, so rows written between calls are deleted too.
  • writeMultiple consumes one read unit per operation and one write kilobyte per successful write. An aborted batch does not give back the identity values its puts generated.
  • getTableUsage records are synthesized: 60-second periods, every unit, storage and throttle count zero, at most 1000 records per call when setLimit is 0. Nothing is metered, and the REST ListTableUsage still returns no records.

Notes & limitations

  • No throughput or storage limits are enforced, and ListTableUsage returns no records.
  • Indexes are recorded for read-back only: queries scan the table, and ORDER BY works on any expression, not only on an indexed or primary key prefix as on the real service.
  • Child tables (parent.child), replicas and multi-region tables, frozen schemas, auto-reclaimable expiry and the service configuration with KMS keys are not implemented.