Is there a way to specify a primary key column in KDB+ which will auto-increment, i.e. like in the traditional RMDS (say, Oracle's Sequence)? - don't need to insert in this column, it will be auto-populated with every new record.
相关问题
- How to produce a formatted date string in Q/KDB?
- Rolling window in multi groups
- q - apply function on table rowwise
- How to ungroup list columns in data.table?
- How to join strings in a table in kdb?
相关文章
- How to ungroup list columns in data.table?
- 从在KDB字符串中提取数(extract number from string in kdb)
- 如何总结从单个记录的多个元素(How to sum multiple elements from s
- How to join strings in a table in kdb?
- Iterate over current row values in kdb query
- KDB+ / Q Syntax optimizations to oneliners
- select column from a table based on a variable nam
- soft deleting a column from a table in q
KDB already has one for in-memory tables - the
i
column. It's basically the 0-based index of each row.Virtual column 'i' is just a index to columns. We can't use it as primary key in all the cases. For ex. if we delete something from table like:
Let's delete a row from t:
It gives you row at that index and not the row corresponding to some column value(primary column in this case). So for such kind of operations, it can't be used as primary key.
Tables will automatically have a hidden (virtual) incrementing column called "i".
If you needed to join on this you could so something like:
Some useful info here http://code.kx.com/q4m3/8_Tables/
Edit - "i" is not a primary key but can be manipulated accordingly