Details
-
Improvement
-
Resolution: Done
-
Major
-
4.0.0
Description
Most SQL engines have a feature called sequences or serials - an atomic counter which is incremented every time it is accessed.
This is used widely for the generation of keys.
Our KV supports a special time of counter documents which can be incremented atomically.
In order to facilitate migration of relational applications to N1QL we should take advantage of the KV counters and create a similar facility as sequences - with DDL and suitable functions to increment and query the sequence values.
As a possible suggestion, somewhat mimicking Oracle:
CREATE SEQUENCE sequenceName IN keyspace WITH (<sequence specs>)
ALTER SEQUENCE keyspace.sequenceName TO (<sequence specs>)
DROP SEQUENCE keyspace.sequenceName
nextval(keyspace.sequenceName) -> Now SQL standard: NEXT VALUE FOR ...
currval(keyspace.sequenceName) -> Now: PREV VALUE FOR ...