Table of Contents
Default KeyValue
Overview
Default KeyValue is the most simple KeyValue in Valentina DB.
This KeyValue is similar to many third-party KeyValue stores in the sense that it takes your KEY and just index it using default comparator.
In ValentinaDB we have decided to use string-based Keys with binary comparator (simple memcmp() function from C).
CREATE
You can create it using
DROP
You can drop Default KeyValue using
- SQL: "DROP KEYVALUE"
WRITE DATA
Writing data into KeyValue is similar to Table's records operations.
API:
SQL:
- KEYVALUE keyvalue_name INSERT ( key:value, … )
- KEYVALUE keyvalue_name UPDATE ( key:value, … )
- KEYVALUE keyvalue_name UPSERT ( key:value, … )
- KEYVALUE keyvalue_name DELETE( key, … )
- KEYVALUE keyvalue_name GET ( key, … )
To understand how they work, imagine that Key is a unique field of the table. Then, it is easy to see that
- insert will throw an exception on inserting key duplicate;
- update expects that key already exists and throw an exception if key is not found;
- upsert is combination of insert and update, and never throws error;
- delete will throw an exception if the key is not found in the store.
READ DATA
You can read data from KeyValue storage with API or SQL approaches:
- API: VKeyValue.Get(key)
- SQL: KEYVALUE GET