SHOW and DESCRIBE

v3.2.0

Inspect tables, columns, indexes, assertions and the workload, with SHOW commands and the sys.* catalog views.

In this article

SHOW and DESCRIBE report the state of the instance: its tables and their structures, its rules, and what the workload has been doing. Each one is a SELECT over one sys.* view and replies with rows, so the same information can be read, filtered and sorted with ordinary SELECT statements.

Commands

CommandReports
SHOW TABLESAll tables, including the system tables, with storage form, root page, the next key to be issued and free column slots (sys.tables).
DESCRIBE <table> (DESC)One row per column: type, NOT NULL, whether it is the primary key, Cabin policy and referenced table (sys.columns).
SHOW NAMESPACESNamespaces, sys and public first.
SHOW INDEXESSecondary indexes with their key and covered columns.
SHOW CABINSCabins with their status, entries, hits and misses.
SHOW FKEYSDeclared foreign keys.
SHOW ASSERTIONSAssertions with enforcing= and counters for checks and violations.
SHOW TRANSITIONSTransitions, each with its table, governed column and declaration.
SHOW PATTERNSThe statement shapes the database has received.
SHOW ACCESSHow each table has been accessed, per access shape, by columns and never by values.
SHOW BUDGETPrimary-key consumption per table: next key, keys issued and remaining, the share used in parts per million, and warning and exhausted flags.
SHOW RELAYOUT [<table>]The physical optimizer’s report of moves it would make and what blocks them.
SHOW CABIN_OPTIMIZERThe Cabins the Cabin controller manages, with their state and scores.
SHOW METAInstance details as section,field,value rows: format version, buffer pool, write-ahead log and checkpoint counters, and what the last startup’s recovery did.
SHOW PAGE <id> [VALUES]One page’s header and slots, for debugging.

Examples

DESCRIBE purchases;
rel_id,rel_name,pos,name,type_val,type,notnull,tuple_key,cabin,references
4013,purchases,0,id,4,int64,1,1,NULL,NULL
4013,purchases,1,account_id,4,int64,1,0,auto,accounts
4013,purchases,2,item_id,4,int64,1,0,auto,items
4013,purchases,3,qty,4,int64,1,0,auto,NULL
4013,purchases,4,bought_on,11,date,1,0,auto,NULL
4013,purchases,5,note,9,varchar,0,0,auto,NULL

tuple_key=1 marks the primary key. The next key to be issued and the keys used are in SHOW BUDGET.

SHOW ASSERTIONS;
assertion_id,name,rel_oid,rel_name,enforcing,checks,violations,reserved,aborted,def
1,purchase_limit,4013,purchases,1,5,0,5,0,CREATE ASSERTION purchase_limit ON purchases GROUP BY (account_id, item_id) CHECK COUNT(*) <= 3
2,seat_limit,4039,tickets,1,9,0,9,0,CREATE ASSERTION seat_limit ON tickets GROUP BY (flight_id) CHECK COUNT(*) <= 4
3,baggage_cap,4039,tickets,1,9,0,9,0,CREATE ASSERTION baggage_cap ON tickets GROUP BY (passenger_id) CHECK SUM(baggage_kg) <= 46

An unknown target is refused: ERR unknown SHOW target 'NOPE' (byte 5).

Catalog views

The catalog is also available as views:

SELECT * FROM sys.tables;
SELECT * FROM sys.columns WHERE rel_id = 4013;
SELECT name FROM sys.tables ORDER BY name LIMIT 2 OFFSET 1;

The views are sys.tables, sys.columns, sys.objects, sys.types, sys.patterns, sys.namespaces, sys.indexes, sys.fkeys, sys.access_stats, sys.relation_stats, sys.cabins, sys.assertions, sys.transitions, sys.relayout, sys.cabin_optimizer, sys.lock_waits, sys.statement_stats, sys.page_slots and sys.meta.

  • WHERE (conditions joined by AND), ORDER BY, LIMIT and OFFSET work on views. Joins, aggregates, OR, NOT, IN lists, LIKE and the query layer’s forms do not:

    kdbs> SELECT COUNT(*) FROM sys.tables
    ERR aggregation over a catalog view (sys.tables) is not supported; a view's rows do not come from a step chain
    
  • Every integer column of a view is a uint64 and every other column a varchar. A literal follows the same rule as on a table: a literal of the wrong type, or a negative integer, is refused with its byte position:

    kdbs> SELECT name FROM sys.tables WHERE oid = '100'
    ERR column 'oid' literal at byte 40: expects an integer literal - unquoted, with no fraction
    

Session commands

CommandReply
PINGPONG
SYNCForces the log and data to disk: OK synced
STOPCloses the connection: OK bye

Sandbox: SYNC and STOP are disabled in the browser sandbox.

See also