Home » SQL & PL/SQL » SQL & PL/SQL » Reference Partitioning (Oracle 11g)
Reference Partitioning [message #604114] Tue, 24 December 2013 04:05 Go to next message
srinivas.k2005
Messages: 404
Registered: August 2006
Senior Member
Hi,

I want to remove the reference partition already created before. Is it possible to remove?

We need to drop and recreate the table? No other options??

Suggestions??


create table customers
(
   cust_id   number primary key,
   cust_name varchar2(200),
   rating    varchar2(1) not null
)
partition by list (rating)
(
   partition pA values ('A'),
   partition pB values ('B')

);

create table sales
(
   sales_id    number primary key,
   cust_id     number not null,
   sales_amt   number,
   constraint  fk_sales_01
    foreign key (cust_id)
    references customers
)
partition by reference (fk_sales_01);

insert into customers values (1,'John','A');

insert into sales values (11,1,200);



Regards,
SRK
Re: Reference Partitioning [message #604118 is a reply to message #604114] Tue, 24 December 2013 04:30 Go to previous messageGo to next message
Michel Cadot
Messages: 68647
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

You want to remove a specific partition or the partitioning?

Re: Reference Partitioning [message #604120 is a reply to message #604118] Tue, 24 December 2013 04:38 Go to previous messageGo to next message
srinivas.k2005
Messages: 404
Registered: August 2006
Senior Member
Entire partitioning "partition by reference (fk_sales_01)" should be removed.
Later table script should look like,

create table sales
(
   sales_id    number primary key,
   cust_id     number not null,
   sales_amt   number,
   constraint  fk_sales_01
    foreign key (cust_id)
    references customers
)


Regards,
SRK
Re: Reference Partitioning [message #604122 is a reply to message #604120] Tue, 24 December 2013 04:42 Go to previous messageGo to next message
Michel Cadot
Messages: 68647
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

You have to recreate the table.
You can use DBMS_REDEFINITION for this, for instance if you have no downtime.

[Updated on: Tue, 24 December 2013 04:44]

Report message to a moderator

Re: Reference Partitioning [message #604126 is a reply to message #604122] Tue, 24 December 2013 04:51 Go to previous messageGo to next message
srinivas.k2005
Messages: 404
Registered: August 2006
Senior Member
Thanks a lot.
Re: Reference Partitioning [message #604132 is a reply to message #604126] Tue, 24 December 2013 07:10 Go to previous messageGo to next message
srinivas.k2005
Messages: 404
Registered: August 2006
Senior Member
Hi,

I am modifying existing partition with interval partitioning.
But oracle not allowing to be used together with partitioning by reference.
I am getting error "SET Interval not legal on this table"

Please advise.

 create table customers
(
   cust_id   number primary key,
   cust_name varchar2(200),
   rating    varchar2(1) not null,
   start_date        DATE not null
     )
  PARTITION BY RANGE (start_date) 
 (  
    PARTITION pos_data_p0 VALUES LESS THAN (TO_DATE('1-7-2007', 'DD-MM-YYYY')),
    PARTITION pos_data_p1 VALUES LESS THAN (TO_DATE('1-8-2007', 'DD-MM-YYYY'))
 ); 
 
 create table sales
(
   sales_id    number primary key,
   cust_id     number not null,
   sales_amt   number,
   constraint  fk_sales_01
    foreign key (cust_id)
    references customers
 )
partition by reference (fk_sales_01);


alter table customers set INTERVAL(NUMTOYMINTERVAL(1, 'MONTH'));



Regards,
SRK
Re: Reference Partitioning [message #604133 is a reply to message #604132] Tue, 24 December 2013 07:18 Go to previous messageGo to next message
Michel Cadot
Messages: 68647
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

You cannot because "partition by reference" on a "partition by interval" table is not supported in 11g.

Re: Reference Partitioning [message #604134 is a reply to message #604133] Tue, 24 December 2013 07:29 Go to previous messageGo to next message
srinivas.k2005
Messages: 404
Registered: August 2006
Senior Member
Any suggestions/Other methods on how to achieve this?

Regards,
SRK
Re: Reference Partitioning [message #604135 is a reply to message #604134] Tue, 24 December 2013 07:32 Go to previous messageGo to next message
Michel Cadot
Messages: 68647
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Achieve what?

Re: Reference Partitioning [message #604138 is a reply to message #604135] Tue, 24 December 2013 07:48 Go to previous messageGo to next message
srinivas.k2005
Messages: 404
Registered: August 2006
Senior Member
Achieve "partition by reference" on a "partition by interval" table. Is it supported in next higher versions?

Thanks a lot Michel.
Re: Reference Partitioning [message #604139 is a reply to message #604138] Tue, 24 December 2013 08:21 Go to previous messageGo to next message
Michel Cadot
Messages: 68647
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

I don't know, I have not a 12c.
So in this version you can't, you have to change what you want.

Re: Reference Partitioning [message #604141 is a reply to message #604138] Tue, 24 December 2013 10:13 Go to previous messageGo to next message
Solomon Yakobson
Messages: 3273
Registered: January 2010
Location: Connecticut, USA
Senior Member
srinivas.k2005 wrote on Tue, 24 December 2013 08:48
Achieve "partition by reference" on a "partition by interval" table. Is it supported in next higher versions?


It is supported in 12C:

SQL> create table customers
  2  (
  3     cust_id   number primary key,
  4     cust_name varchar2(200),
  5     rating    varchar2(1) not null,
  6     start_date        DATE not null
  7       )
  8    PARTITION BY RANGE (start_date)
  9   (
 10      PARTITION pos_data_p0 VALUES LESS THAN (TO_DATE('1-7-2007', 'DD-MM-YYYY')),
 11      PARTITION pos_data_p1 VALUES LESS THAN (TO_DATE('1-8-2007', 'DD-MM-YYYY'))
 12   );

Table created.

SQL>
SQL>  create table sales
  2  (
  3     sales_id    number primary key,
  4     cust_id     number not null,
  5     sales_amt   number,
  6     constraint  fk_sales_01
  7      foreign key (cust_id)
  8      references customers
  9   )
 10  partition by reference (fk_sales_01);

Table created.

SQL>
SQL>
SQL> alter table customers set INTERVAL(NUMTOYMINTERVAL(1, 'MONTH'));

Table altered.

SQL>


SY.
Re: Reference Partitioning [message #604142 is a reply to message #604141] Tue, 24 December 2013 11:47 Go to previous messageGo to next message
srinivas.k2005
Messages: 404
Registered: August 2006
Senior Member
Vow! Thank you...we can implement in 12C
Re: Reference Partitioning [message #604210 is a reply to message #604142] Thu, 26 December 2013 05:38 Go to previous messageGo to next message
srinivas.k2005
Messages: 404
Registered: August 2006
Senior Member
Hi,

I need to remove the interval partitioning extension already created using alter command before. Please advise

 create table customers
(
   cust_id   number primary key,
   cust_name varchar2(200),
   rating    varchar2(1) not null,
   start_date        DATE not null
     )
  PARTITION BY RANGE (start_date) 
 (  
    PARTITION pos_data_p0 VALUES LESS THAN (TO_DATE('1-7-2007', 'DD-MM-YYYY')),
    PARTITION pos_data_p1 VALUES LESS THAN (TO_DATE('1-8-2007', 'DD-MM-YYYY'))
 ); 

alter table customers set INTERVAL(NUMTOYMINTERVAL(1, 'MONTH'));




Regards,
SRK


Re: Reference Partitioning [message #604212 is a reply to message #604210] Thu, 26 December 2013 05:55 Go to previous messageGo to next message
Michel Cadot
Messages: 68647
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

What is the question?

Re: Reference Partitioning [message #604214 is a reply to message #604212] Thu, 26 December 2013 06:02 Go to previous messageGo to next message
srinivas.k2005
Messages: 404
Registered: August 2006
Senior Member
I need to remove the interval partitioning extension.
Table should not allow to Insert the values for the date beyond Aug 2007.

Regards,
SRK
Re: Reference Partitioning [message #604215 is a reply to message #604214] Thu, 26 December 2013 06:06 Go to previous messageGo to next message
Michel Cadot
Messages: 68647
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

There is still no question in your post. A question ends with a question mark and has a specific syntax.

Quote:
I need to remove the interval partitioning extension.


You have to recreate the table.

Re: Reference Partitioning [message #604216 is a reply to message #604210] Thu, 26 December 2013 06:21 Go to previous messageGo to next message
flyboy
Messages: 1903
Registered: November 2006
Senior Member
Fortunately, some kind guys from Oracle already took an effort to describe the features which are provided in their database.
Books containing this kind of information are called documentation and they are available e.g. online on http://tahiti.oracle.com/

When using some of them, what at about consulting the documentation firstly? For 11gR2, interval partitioning clause is described here: http://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_3001.htm#SQLRF53434
Re: Reference Partitioning [message #604217 is a reply to message #604215] Thu, 26 December 2013 06:28 Go to previous messageGo to next message
srinivas.k2005
Messages: 404
Registered: August 2006
Senior Member
Thanks Michel.

Question regarding Reference partitioning:

How to get ONLY those table names/details having BOTH partition by reference and partitioned by reference to parent tables?

From "user_part_tables.partitioning_type", we get partitioned by reference to parent tables[where partitioning_type ='REFERENCE']( Child table details).

But, how to get partition by reference tables ( Parent table details)?


Regards,
SRK

Re: Reference Partitioning [message #604219 is a reply to message #604217] Thu, 26 December 2013 06:40 Go to previous messageGo to next message
srinivas.k2005
Messages: 404
Registered: August 2006
Senior Member
Thanks flyboy.

Below alter statement works for disable interval partitioning.

alter table ipart set INTERVAL();

Regards,
SRK
Re: Reference Partitioning [message #604222 is a reply to message #604219] Thu, 26 December 2013 07:22 Go to previous messageGo to next message
srinivas.k2005
Messages: 404
Registered: August 2006
Senior Member
Hi,

Question regarding Reference partitioning:

How to get ONLY those table names/details having BOTH partition by reference and partitioned by reference to parent tables?

From "user_part_tables.partitioning_type", we get partitioned by reference to parent tables[where partitioning_type ='REFERENCE']( Child table details).

But, how to get partition by reference tables ( Parent table details)? Suggestions??


Regards,
SRK
Re: Reference Partitioning [message #604236 is a reply to message #604222] Thu, 26 December 2013 08:42 Go to previous messageGo to next message
Solomon Yakobson
Messages: 3273
Registered: January 2010
Location: Connecticut, USA
Senior Member
srinivas.k2005 wrote on Thu, 26 December 2013 08:22
But, how to get partition by reference tables ( Parent table details)?


Using your CUSTOMERS/SALES example:

SQL> create table customers
  2  (
  3     cust_id   number primary key,
  4     cust_name varchar2(200),
  5     rating    varchar2(1) not null
  6  )
  7  partition by list (rating)
  8  (
  9     partition pA values ('A'),
 10     partition pB values ('B')
 11  
 12  );

Table created.

SQL> 
SQL> create table sales
  2  (
  3     sales_id    number primary key,
  4     cust_id     number not null,
  5     sales_amt   number,
  6     constraint  fk_sales_01
  7      foreign key (cust_id)
  8      references customers
  9  )
 10  partition by reference (fk_sales_01);

Table created.

SQL> 
SQL> select  a.owner child_table_owner,
  2          a.table_name child_table_name,
  3          c.owner parent_table_owner,
  4          c.table_name parent_table_name
  5    from  dba_part_tables a,
  6          dba_constraints b,
  7          dba_constraints c
  8    where a.owner = 'SCOTT'
  9      and b.table_name = 'SALES'
 10      and b.owner = a.owner
 11      and b.constraint_name = a.ref_ptn_constraint_name
 12      and c.owner = b.r_owner
 13      and c.constraint_name = b.r_constraint_name
 14  /

CHILD_TABL CHILD_TABL PARENT_TAB PARENT_TAB
---------- ---------- ---------- ----------
SCOTT      SALES      SCOTT      CUSTOMERS

SQL> 


SY.
Re: Reference Partitioning [message #604259 is a reply to message #604236] Thu, 26 December 2013 23:20 Go to previous message
srinivas.k2005
Messages: 404
Registered: August 2006
Senior Member
Thanks a lot:)
Previous Topic: REGEXP
Next Topic: find no of times a column is queried on a table
Goto Forum:
  


Current Time: Fri Apr 26 14:32:03 CDT 2024