sqlDelete

Syntax

sqlDelete(table, [where])

Arguments

table can be an in-memory table or a distributed table.

where is a metacode indicating the where condition.

Details

Dynamically generate a metacode of the SQL delete statement. To execute the generated metacode, please use function eval.

Examples

Example 1. Delete the records in an in-memory table

$ t1=table(`A`B`C as symbol, 10 20 30 as x)
$ sqlDelete(t1, <symbol=`C>).eval()
$ t1;

symbol

x

A

10

B

20

Example 2. Delete the records in a distributed table

$ if(existsDatabase("dfs://db1")){
$     dropDatabase("dfs://db1")
$ }

$ n=1000000
$ t=table(take(`A`B`C`D,n) as symbol, rand(10.0, n) as value)
$ db = database("dfs://db1", VALUE, `A`B`C`D)
$ Trades = db.createPartitionedTable(t, "Trades", "symbol")
$ Trades.append!(t)
$ select count(*) from Trades;

1000000

$ Trades=loadTable("dfs://db1", "Trades")
$ sqlDelete(Trades, <symbol=`A>).eval()
$ select count(*) from Trades;

750000