在DolphinDB中怎么实现INSERT INTO t1(c1,c2) select c1,c2 from t2

下面是我的一个例子,其中有2张表,第一张表t有2列,第2张表addTable有多列,现在想把t的数据插入addTable:

t=table(1..3 as id,`a`b`c as v)
addTable=table(1..3 as id,`x`y`z as v1,5..7 as v2,6.0 6.1 6.2 as v3)
insert into addTable(id,v1)values(4,"test")
insert into addTable(id,v1) select id,v from t

上面第一个insert语句即往addTable插入一行记录能成功执行,但第二个insert语句报错:

The number of columns in the name list doesn't match the number of columns in the value list.

请问一下这个是我用错了,还是DolphinDB database不支持 insert table1 (col1,col2)select col1,col2 from table2?这种功能怎么写,遍历源table一行一行插入目的Table?有没有方法支持插入部分列,剩余的列不插入?

请先 登录 后评论

1 个回答

logger

上面的例子可以用下面的方法:

insert into addTable(id,v1) values(t.id, t.v)


请先 登录 后评论