How to truncate or delete partition from db2 using bigsql?

3.6k views Asked by At

I have table in db2 (using bigsql) that is partitioned as per date on IBM BigInsights

table_name_abc
   20150810
      data corresponding to partition
   20150811
      data corresponding to partition
   ....

what I want is to delete particular partition say 20150810 or delete data from that partition

I tried this

db2 "truncate table test_schema.table_name_abc where partition_date = 20150810";

But it gave following error

DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:
SQL0104N  An unexpected token "where" was found following "test_table".
Expected tokens may include:  "".  SQLSTATE=42601

Can someone please instruct on how to do this?

1

There are 1 answers

0
Raunak Kathuria On

Solved it by using the following command

db2 "ALTER TABLE test_schema.table_name_abc DROP PARTITION (partition_date = 20150515)";

Adding it as answer just in case someone needs it