插入数据
我们可以使用 append! 或 tableInsert 函数往数据表中插入数据。即使只插入一条数据,也要用表的形式来表示新增的数据。
请注意:若数据库为 VALUE 分区,且分区列为字符串类型,则追加的分区列数据不能包含空格,“/n”, “/r”, “/t”。
在以下例子中,把表t中的数据追加到分区表pt。
$ n=1000000
$ ID=rand(10, n)
$ x=rand(1.0, n)
$ t=table(ID, x)
$ db=database("dfs://rangedb", RANGE, 0 5 10)
$ pt=db.createPartitionedTable(t, `pt, `ID)
$ pt.append!(t);
$ //等价于pt.tableInsert(t)
$ select count(x) from pt;
count_x |
---|
1000000 |