构造q命令获取所有表的元数据

Construct q command to get metadata for all tables

我想构建一个查询来检索每个 table 的 table 元数据。

我可以使用 meta 函数获取单个 table 的元数据。我可以将其与 tables \`. 链接起来,returns . 命名空间中的所有 table,以构建 (meta')tables `..

这几乎是我想要的,因为它是 returns 元数据列表 table。问题是我不知道哪个元数据 table 属于哪个 kdb table。

理想情况下,我可以构造一个 returns 一个 table 的查询,其中每一行是 table 名称 + meta tablename 的结果。对构建此类查询有何建议?

q)trade:([] sym: 10?`4; time:10?.z.t; prx:10?100f; sz:10?10000);
q)quote:([] sym: 10?`4; time:10?.z.t; bPrx:10?100f; aPrx:10?100f; bSz:10?10000; aSz:10?10000);
q)testTable:update `s#a from ([] a:til 10; b: 10?`3; c:10?.z.p);
q)raze {update table:x from 0!meta x}'[tables[]]
    c    t f a table
    --------------------
    sym  s     quote
    time t     quote
    bPrx f     quote
    aPrx f     quote
    bSz  j     quote
    aSz  j     quote
    a    j   s testTable
    b    s     testTable
    c    p     testTable
    sym  s     trade
    time t     trade
    prx  f     trade
    sz   j     trade

I could construct a query which returns a table where each row is tablename + results of "meta tablename". Any advice for constructing such a query?

如果你确实想这样做,有很多方法。一个例子:

q)update tableMeta:meta'[table] from ([] table:tables[])
    table     tableMeta
    --------------------------------------------------------------------------------
    quote     (+(,`c)!,`sym`time`bPrx`aPrx`bSz`aSz)!+`t`f`a!("stffjj";``````;``````)
    testTable (+(,`c)!,`a`b`c)!+`t`f`a!("jsp";```;`s``)
    trade     (+(,`c)!,`sym`time`prx`sz)!+`t`f`a!("stfj";````;````)