Reference Partitioning [message #604114] |
Tue, 24 December 2013 04:05 |
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 #604120 is a reply to message #604118] |
Tue, 24 December 2013 04:38 |
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 #604132 is a reply to message #604126] |
Tue, 24 December 2013 07:10 |
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 #604141 is a reply to message #604138] |
Tue, 24 December 2013 10:13 |
Solomon Yakobson
Messages: 3273 Registered: January 2010 Location: Connecticut, USA
|
Senior Member |
|
|
srinivas.k2005 wrote on Tue, 24 December 2013 08:48Achieve "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 #604210 is a reply to message #604142] |
Thu, 26 December 2013 05:38 |
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 #604217 is a reply to message #604215] |
Thu, 26 December 2013 06:28 |
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 #604222 is a reply to message #604219] |
Thu, 26 December 2013 07:22 |
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 |
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.
|
|
|
|