在KDB中,如何大容量插入到包含String类型列的表中



在具有字符串(而非符号)类型列的表中,我可以逐个插入一行。但是批量插入不起作用!

    t:([id:`int$()] str:()) /create table
    `t insert(0, enlist enlist "test") /insert first row. This seems to need two enlist
    `t insert(1, enlist "test1") /insert one more, this time with one enlist
    `t insert (2 3; enlist "test2" enlist "test3") /trying to bulk insert fails
    `t insert flip (2 3; enlist "test2" enlist "test3") /trying to bulk insert with flip also fails

在插入命令中,我更喜欢分号而不是逗号。这使语法更加简单,也使其易于理解。由于逗号语法的原因,第一次插入时需要2个登记。

用于大容量插入的语法不正确。它非常简单,如下所示:

   q)   t:([id:`int$()] str:())  / create table
   q) `t insert (0;enlist "test")   / insert first row
   q)  `t insert (1 2;("test1";"test2"))  / bulk insert 2 rows

最新更新