[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 336
  • Last Modified:

Oracle

Hi,

I want to change the existing table LIST partition to LIST-LIST partition without disturbing the existing data.

Ex. I have
table table1(A varchar2(10), B varchar2(10))
partition by list(A)
( partition data_x values('x'),
  partition data_y values('y')
);

Now I would like to alter the table like below

table table1(A varchar2(10), B varchar2(10))
partition by list(A)
subpartition by list(B)
( partition data_x values('x')
  (subpartition data_x_10 values('10')
   subpartition data_x_20 values('20')
  ),
 partition data_y values('y')
  ( subpartition data_y_10 values('10')
    subpartition data_y_20 values('20')
   )
);

Can you please let me know if this is possible. I mean without dropping the table can I add subpartition? If possible can you please suggest how can I do this?

Also I need to rebuild the index which is existing on the existing list partition as am adding subpartions to it.

Thank you.
0
GouthamAnand
Asked:
GouthamAnand
  • 5
  • 2
  • 2
2 Solutions
 
GouthamAnandAuthor Commented:
And also currently index exists on the List partition
like
CREATE INDEX table1_IDX1 ON table1 (A)
LOCAL (  
  partition data_x,
  partition data_y
)
 
I need to rebuild the index on the newly created list-list partition.
Can you also please suggest how can i rebuild the index also?

Thanks.
0
 
MikeOM_DBACommented:
It is possible by using the DBMS_REDEFINITION package.

Checkout this article: Zero Downtime Technique to Rebuild Oracle Tables
0
 
Naveen KumarProduction Manager / Application Support ManagerCommented:
The composite partioning list within list has a different syntax as posted below...

CREATE TABLE composite_list_list (
cust_id     NUMBER(10),
cust_name   VARCHAR2(25),
cust_state  VARCHAR2(2),
time_id     DATE)
PARTITION BY LIST(cust_state)
SUBPARTITION BY LIST (cust_id)
SUBPARTITION TEMPLATE(
SUBPARTITION beg VALUES (1,3,5) TABLESPACE part1,
SUBPARTITION mid VALUES (2,4,6) TABLESPACE part2,
SUBPARTITION end VALUES (7,8,9,0) TABLESPACE part3) (
PARTITION west VALUES ('OR', 'WA'),
PARTITION east VALUES ('NY', 'CT'),
PARTITION cent VALUES ('IL', 'MN'));

Refer to this link for more information : http://psoug.org/reference/partitions.html

first create the new table with the list-list partioning and then insert your data from the existing table into this new table. Once this is done, you can then create indexes/rename etc.

try it out in your dev/test database as i have not tested this approach.

Thanks,
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
GouthamAnandAuthor Commented:
Hi Thank you. I could create a new table with the given syntax ie using (Template syntax).
 
Comparing with your example, currently I have partition like
CREATE INDEX composite_list_list_IDX1 ON composite_list_list (cust_state)
LOCAL (  
  partition west ,
  partition east,
  partition cent)

How this Index creation syntax will get changed when subpartitions also exists.
Do i need to mention the subpartions also for faster execution of the queries.

Can you please suggest?

Thanks.
0
 
GouthamAnandAuthor Commented:
I mean I have one b-tree index on cust_state and bitmap index on cust_id currenlty. so I can create the same way after the creation of new table(with subpartions) by mentioning only the patitions and not mentioning the subpartitions?

Thanks.
0
 
Naveen KumarProduction Manager / Application Support ManagerCommented:
hi,

I have not used subpartitions in the indexe creations so far - so i cannot comment on this. May be you can await other experts comments. But you can proceed to test your local index with partitions as mentioned in that example for testing right.

Regarding the performance, i would only say the best is to set them up and test it out.

Thanks,
0
 
GouthamAnandAuthor Commented:
Ok. Regarding  inserting my data from the existing table into this new table,
my existing table is of having 9 gb data(500,00,000 records). Am currenlty copying like

insert into T1 select * from T2.

But this is taking more time. Is there any better (faster)way to copy from existing table to new table?

Thank you.
0
 
MikeOM_DBACommented:
Read the article from the link I posted...
0
 
GouthamAnandAuthor Commented:
Thank you for all your help. I could copy the table very quickly with DBMS_REDEFINITION package. Thanks a lot for the information.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now