# `meta`

_Metadata for a table_
```syntax
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
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
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
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
```

> **Warning — `meta` examines only the first item in each column**
>
>
> As a result, `meta` can't tell you whether you can [splay](../how_to/interact_with_databases/splayed-tables.md) a table in memory.
>
> ```q
> 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
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.
```bash
❯ q db
```
```q
q)\v
`s#`sym`tr
q)meta tr
c    | t f a
-----| -----
date | d
time | u
vol  | j
inst | s
price| f
```

---

[Metadata](metadata.md)


[Splayed tables](../how_to/interact_with_databases/splayed-tables.md)
