meta¶
Metadata for a table
meta x meta[x]
Where x is a
- table in memory or memory mapped (by value or reference)
- filesymbol for a splayed table
returns a table keyed by column name, with columns:
| column | meaning |
|---|---|
c |
column name |
t |
data type |
f |
foreign key (enumerations) |
a |
attribute |
q)trade:([]time:09:30:00.000 09:31:00.000;sym:`a`b;price:10.75 11.5;size:100 200i)
q)meta trade
c | t f a
-----| -----
time | t
sym | s
price| f
size | i
q)meta `trade
c | t f a
-----| -----
time | t
sym | s
price| f
size | i
q)`sym xasc`trade; / sort by sym, setting the sorted attribute
q)meta trade
c | t f a
-----| -----
time | t
sym | s s
price| f
size | i
The f column shows the table a foreign-key column refers to:
q)f:([k:1 2]v:3 4)
q)x:([]a:`f$1 2 1;b:3 4 5)
q)meta x
c| t f a
-| -----
a| j f
b| j
The t column shows the column type. A lowercase letter indicates atomic items, and an uppercase letter indicates lists. The type is blank for a column that is a mixed list.
q)show u:([] code:`F1; vr:(enlist 2.3))
code vr
--------
F1 2.3
q)meta u
c | t f a
----| -----
code| s
vr | f
q)show v:([] code:`F2; vr:(enlist (5.4; 43.2)))
code vr
-------------
F2 5.4 43.2
q)meta v
c | t f a
----| -----
code| s
vr | F
meta examines only the first item in each column
As a result, meta can't tell you whether you can splay a table in memory.
q)meta ([]a:(1 2;`a`b))
c| t f a
-| -----
a| J
A splayed table with a symbol column needs its corresponding sym list.
q)tr:([]date:2#2026.01.02;time:09:30 09:31;vol:100 200;inst:`a`b;price:1.5 2.5)
q)`:db/tr/ set .Q.en[`:db;tr]
`:db/tr/
q)delete sym from `. / as in a new session
`.
q)meta `:db/tr
'..sym
[0] meta `:db/tr
^
q)load `:db/sym / required for meta to describe db/tr
`sym
q)meta `:db/tr
c | t f a
-----| -----
date | d
time | u
vol | j
inst | s
price| f
Loading a database memory-maps its tables and loads its sym list, so meta works without loading the sym file separately.
❯ q db
q)\v
`s#`sym`tr
q)meta tr
c | t f a
-----| -----
date | d
time | u
vol | j
inst | s
price| f