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, anopc-work-request-idheader and no body. The work request is alreadySUCCEEDEDwithtimeFinishedset, and its one resource isentityType: TABLE,actionTypeCREATED,UPDATEDorDELETED, andidentifierthe table OCID. Terraform'soci_nosql_tableandoci_nosql_indexwait on exactly that resource. - The work request
operationTypeenum has onlyCREATE_TABLE,UPDATE_TABLE,DELETE_TABLEandUPDATE_CONFIGURATION, so CreateIndex, DeleteIndex and ChangeTableCompartment all reportUPDATE_TABLE. {tableNameOrId}is the table OCID, or the table name together withcompartmentId. A name withoutcompartmentIdis400 MissingParameter. Table names match case-insensitively.ddlStatementis 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
DELETEDtombstone. A name lookup, a write or a query no longer finds it, and the name can be reused. ListTables omitsDELETEDtables unlesslifecycleState=DELETEDorALLasks for them. - Lists are wrapped (
{"items":[…]}) and paginate withlimit,pageandopc-next-page.TableCollectionalso carriesautoReclaimableTables,onDemandCapacityTablesand an emptyavailableReplicationRegions. - Condition failures are results, not errors. An UpdateRow whose
option(IF_ABSENT,IF_PRESENT) orif-matchversion does not hold is a200withoutversion; withisGetReturnRowit carriesexistingVersionandexistingValue. A DeleteRow that finds no row, or whoseif-matchdoes not match, is a200withisSuccess: false. - GetRow and DeleteRow take
keyas a repeated query parameter, onecolumn:valueper primary key column:?key=tenant:acme&key=id:1. etagon UpdateRow and GetRow is the row version.- Query takes
limit/pageand returns{"items":[…], "usage":{…}}withopc-next-page; withoutlimita 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
GENERATEDidentity and UUID columns;generatedValuereturns the generated value. Giving a value for aGENERATED ALWAYSidentity column is400 InvalidParameter. - Fields that are not columns are ignored, and missing columns take their
DEFAULTor null, unlessisExactMatchis true, which makes either a400. ttl(days) sets the row's expiry;0means never. Without it, a new row takes the table's default TTL and an existing row keeps its expiry, unlessisTtlUseTableDefaultis set. GetRow reportstimeOfExpiration. Expired rows are hidden at once and deleted by a sweep everyttl-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.cityorinfo.city),+ - * /, and the aggregatescount(*),count,min,max,sumandavg. - Variables come from QueryDetails
variables, keyed with or without$. A declared variable with no value is400. isPrepared: truetakes thestatementPrepareStatement 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, isILLEGAL_ARGUMENT. More than 50 operations isBATCH_OP_NUMBER_LIMIT_EXCEEDED(BatchOperationNumberLimitException), the limitBinaryProtocol.BATCH_OP_NUMBER_LIMITstates. When an operation added withabortIfUnsuccessfulfails (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 isgetSuccess() == falsewithgetFailedOperationIndex()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
FieldRangeon the next primary key column; anything else isILLEGAL_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
setLimitandsetStartIndex;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. ASignatureProvidersigns 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-idheader, whichSignatureProvidersends from the request's compartment,NoSQLHandleConfig.setDefaultCompartment, or else the tenancy OCID. Only compartment OCIDs are understood, not compartment names. An unknown compartment is errorRESOURCE_NOT_FOUND(ResourceNotFoundException). - Errors are HTTP
200with an NSON body of error code and message, as the drivers expect: a missing table isTABLE_NOT_FOUND, an existing oneTABLE_EXISTS, an indexINDEX_NOT_FOUNDorINDEX_EXISTS, an etag mismatchETAG_MISMATCH, any other rejectionILLEGAL_ARGUMENT(IllegalArgumentExceptionin Java) with the same message the REST API gives. A body that is not valid NSON isBAD_PROTOCOL_MESSAGE. - Every response echoes
x-nosql-request-id; the Java driver discards a response without it. - Table operations finish at once:
tableRequestreturnsACTIVE(orDROPPED), sowaitForCompletionreturns 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
Versionfrom the driver matches the RESTetagof 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
200with novalueand noetag. - The table OCID type is
ocid1.nosqltable. - A table created without
tableLimitsisON_DEMANDwith 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, withIF NOT EXISTS, a succeeded work request naming the existing table. A duplicate index name is the same409. ddlStatementafter 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
typeis the upper-case DDL spelling (INTEGER,TIMESTAMP(3),ARRAY(STRING)); a UUID column isSTRINGwithisAsUuid. 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.ttlfor an hour-based TTL is rounded up to whole days.- Row versions are opaque base64 counters, and the row
etagequals the version. usageunits are nominal: one read or write unit per row operation, and one read unit per row scanned by a query.- ListTables sorts by
timeCreateddescending by default; ListIndexes bynameascending. - 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;
queryPlanis 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()andgetQuerySchema()are null. - Query pages are taken by
setLimitalone;setMaxReadKBandsetMaxMemoryConsumptionare 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 RESTddlStatementdoes.- 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 andns:tablenames, and thelastWriteMetadatarow 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
setLimitis 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.