Apr 1, 2020

Interval partitioning

I received a request to add a partition automatically on every data based on date. Assume up to 2000 one partition but after for each date partition to be created based on a date column.

Here is the example:

CREATE TABLE sales
  ( prod_id       NUMBER(6)
  , time_id       DATE
  , quantity_sold NUMBER(3)
  )
 PARTITION BY RANGE (time_id) INTERVAL (NUMTODSINTERVAL(1,'DAY'))
 (PARTITION before_2000 VALUES LESS THAN (TO_DATE('01-JAN-2000','dd-MON-yyyy'))
  );

-- Your test data like some thing like this
insert into sales values(9,'9-Jan-2005',100);
commit;

-- To see all partition tables

select * from USER_TAB_PARTITIONS where table_name='SALES';

9 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. This comment has been removed by a blog administrator.

    ReplyDelete
  4. This comment has been removed by a blog administrator.

    ReplyDelete
  5. This comment has been removed by a blog administrator.

    ReplyDelete
  6. This comment has been removed by a blog administrator.

    ReplyDelete
  7. Have you been a victim of crypto wallet attacks? Here’s a way to quickly recover your crypto wallet and assets if you’ve been in similar situation, I was recently a victim of crypto wallet attacks and I lost access to my BTC and ETH funds. I was drowning in debt, until I approached a legal firm who recommended I contacted MorphoHack, a data recovery and funds recovery team, who helped me trace and regained access to my crypto wallet with my funds fully recovered. MorphoHack are simply magnificent individuals, with a professional direct approach to the situation, and countless others have been able to recover their crypto, funds lost due to scam, data, personal data recovery. MorphoHack are truly ethical hackers, with well advanced technology to help in any case. I highly recommend their service and fortunately, MorphoHack can be reached easily via email below
    morphohack@cyberservices.com

    ReplyDelete

Translate >>