QStudio
Query kdb+ Servers and Chart Results.
Kdb+ supports keyed tables, these tables have one or more columns designated as primary keys, allowing the use of their unique values to lookup entries.
A keyed table is a dictionary from one table of keys to another table of values with an equal number of rows. We can define it as such or we can use the shorter table syntax. Where we place the key columns inside square braces.
The functions xkey and 0!,1!,2!.. allow setting and removing key columns:
Whereas insert always appended data to unkeyed tables for keyed tables we use upsert. Upsert has two different behaviours, if there is an existing key -> update the values else if it's a new key -> insert.
You do not need to upsert all value columns.
Tables with more than one key column use compound keys for access and upserts. New Data must contain values for all key columns to allow upserts to succeed.
Keyed tables can be accessed in many ways including:
Compound keys work similar to single keys, the table format retrieving values is recommended as being more clear in it's intent and easier for other developers to read.
One feature to be aware of is that key uniqueness is not enforced on table creation or when using xkey. Below we demonstrate how we can create a table with repeated keys and the behaviour of accessing such a table.
Query kdb+ Servers and Chart Results.