I have defined the DFS table schema and write test data into it.
Now, I want to delete all test data but keep my table schema, how?
Suppose I have the following DFS table:
n=1000000
ID=rand(150, n)
dates=2017.08.07..2017.08.11
date=rand(dates, n)
x=rand(10.0, n)
t=table(ID, date, x)
dbDate = database(, VALUE, 2017.08.07..2017.08.11)
dbID = database(, RANGE, 0 50 100 150)
dbName="dfs://compoDB"
if(existsDatabase(dbName)){
dropDatabase(dbName)
}
db = database(dbName, COMPO, [dbDate, dbID])
pt = db.createPartitionedTable(t, `pt, `date`ID)
pt.append!(t);
You can use DolphinDB built-in function truncate.
Let’s conduct a test.
Return:
truncate
function (takes around 100ms).Return:
All your records are removed.