Drop subpartitions
Hi,
Is it possible to drop sub partitions when foreign keys are enabled on the table? I am cleaning up even in the parent tables.
I tried dropping and truncating the subpartitions but can't do it while the foreign keys are enabled. It allows me to delete the data and then drop the empty subpartitions though.
Any help is appreciated.
Thanks
SC
It will be really useful if you could copy and paste what exactly you are doing. Please remember to enclose your observation with the tags so it preserves the code formatting.
Regards
Raj
Similar Messages
-
Managing Partitions: exclusive access?
I have a partitioned table, each partition has 2 subpartitions except for CPART0 which has 1 subpartition.
For this example, assume each partition holds a days data and we have 5 partitions (we have many more depending on volume and number of days stored)
Partitions: CPART0 - CPART4
Subpartitions: keep and other
CPART0 < monday CPART0_keep This partition always holds old data we need to keep for awhile.
CPART1 < tuesday CPART1_keep CPART1_other
CPART2 < wednesday CPART2_keep CPART2_other
CPART3 < thursday CPART3_keep CPART3_other
CPART4 < friday CPART4_keep CPART4_other
When data comes in for friday, we want to drop tuesday but merge data in CPART1_keep subpartition
with CPART0_keep subpartition. We then add a new partition CPART1 with a high value < saturday
The keep subpartitions always get rolled into the cpart0keep partition.
What we do (using Pro C/C++) is:
alter table archive drop subpartition CPART1_other;
alter table archive merge partition CPART0 into CPART1;
alter table archive rename partition CPART1 to CPART0;
alter table archive rename subpartition CPART1_keep to CPART0_keep;
for 6 indexes:
alter index .. rename partition CPART1 to CPART0;
alter index .. rename subpartition CPART1_keep to CPART0_keep;
alter table archive modify subpartition CPART0_keep rebuild unusable local indexes.
alter table archive add partition CPART1 values less than ( saturday ) tablespace xxx;
In doing some volume testing we are seeing that the "rollover" of data will take 5 - 20 minutes.
My question is whether exclusive access is needed to do the alter table commands above.
We did get this error once when trying to prepare the rename partition statement:
ORA-00054: resource busy and acquire with NOWAIT specified (-4)
I had to manually fix and add the new partition.
Is exclusive access needed for 'alter table rename' ? What about drop, merge or add partition?
If it is the renames that need exclusive access, we can probably just not do any renames.
( the 1-subpartition old data can rotate thru CPARTx partitions )
Can we insert data in partitions not involved in the "rolling over" while the rollover to a new day is
in progress? What about queries?
thanks for any help or comments,
LisaOWA is not good enough because OWA doesn't notify you when there is a new email message. If the partners only had OWA, they would miss lots of time sensitive emails and meeting reminders and we don't want to forward the messages and attachments to
their other email address.
OWA does notify you when a new email arrives. It even makes the message arrival sound.
CRM Advisor -
I am using oracle11g. I want to truncate subpartition on specific partion.
I have partition on statewise. Each state partion has 7 day partition.
For intance,
Partion TX
Sub partition MON, TUE, WED, THU, FRI, SAT, SUN
Partion CA
Sub partition MON, TUE, WED, THU, FRI, SAT, SUN
Partion IA
Sub partition MON, TUE, WED, THU, FRI, SAT, SUN
Now i want to perform following tasks.
1. Need to truncate TUE sub partiion on TX partition.
2. Need to truncate WED sub partiion on CA partition.
3. Need to truncate SUN sub partiion on IA partition.
How do we do this?
The below statment truncate all TUE partition on all the partitions.
ALTER TABLE TRX_TABLE
TRUNCATE SUBPARTITION TUE;
How do i tuncate specfic sub partition on specific partition?
Any help is appreciated!!SQL> CREATE TABLE tbl(
2 state VARCHAR2(2),
3 day VARCHAR2(3)
4 )
5 PARTITION BY LIST(state)
6 SUBPARTITION BY LIST(day)
7 SUBPARTITION TEMPLATE (
8 SUBPARTITION mon VALUES('MON'),
9 SUBPARTITION tue VALUES('TUE'),
10 SUBPARTITION wed VALUES('WED'),
11 SUBPARTITION thu VALUES('THU'),
12 SUBPARTITION fri VALUES('FRI'),
13 SUBPARTITION sat VALUES('SAT'),
14 SUBPARTITION sun VALUES('SUN')
15 )
16 (
17 PARTITION tx VALUES('TX'),
18 PARTITION ca VALUES('CA'),
19 PARTITION ia VALUES('IA')
20 )
21 /
Table created.
SQL> select table_name,
2 partition_name,
3 subpartition_name
4 from user_tab_subpartitions
5 where table_name = 'TBL'
6 order by partition_name,
7 subpartition_name
8 /
TABLE_NAME PARTITION_NAME SUBPARTITION_NAME
TBL CA CA_FRI
TBL CA CA_MON
TBL CA CA_SAT
TBL CA CA_SUN
TBL CA CA_THU
TBL CA CA_TUE
TBL CA CA_WED
TBL IA IA_FRI
TBL IA IA_MON
TBL IA IA_SAT
TBL IA IA_SUN
TABLE_NAME PARTITION_NAME SUBPARTITION_NAME
TBL IA IA_THU
TBL IA IA_TUE
TBL IA IA_WED
TBL TX TX_FRI
TBL TX TX_MON
TBL TX TX_SAT
TBL TX TX_SUN
TBL TX TX_THU
TBL TX TX_TUE
TBL TX TX_WED
21 rows selected.
SQL> alter table tbl drop subpartition tx_mon
2 /
Table altered.
SQL> select table_name,
2 partition_name,
3 subpartition_name
4 from user_tab_subpartitions
5 where table_name = 'TBL'
6 order by partition_name,
7 subpartition_name
8 /
TABLE_NAME PARTITION_NAME SUBPARTITION_NAME
TBL CA CA_FRI
TBL CA CA_MON
TBL CA CA_SAT
TBL CA CA_SUN
TBL CA CA_THU
TBL CA CA_TUE
TBL CA CA_WED
TBL IA IA_FRI
TBL IA IA_MON
TBL IA IA_SAT
TBL IA IA_SUN
TABLE_NAME PARTITION_NAME SUBPARTITION_NAME
TBL IA IA_THU
TBL IA IA_TUE
TBL IA IA_WED
TBL TX TX_FRI
TBL TX TX_SAT
TBL TX TX_SUN
TBL TX TX_THU
TBL TX TX_TUE
TBL TX TX_WED
20 rows selected.SY. -
Composite range - range partitioning gives ORA-14202
i am trying to do e composite range - range partitioning, but the table is not created. i get an error, which i cannot look up at ora-codes, it says : value is to high for subpartition, which confuses me...
CREATE TABLE "NJ_VE_AERIAL_RDT"
( "RASTERID" NUMBER NOT NULL ENABLE,
"BANDBLOCKNUMBER" NUMBER NOT NULL ENABLE,
"PYRAMIDLEVEL" NUMBER NOT NULL ENABLE,
"ROWBLOCKNUMBER" NUMBER NOT NULL ENABLE,
"COLUMNBLOCKNUMBER" NUMBER NOT NULL ENABLE,
"FILENAME" VARCHAR2(100 CHAR) NOT NULL ENABLE,
"FILESIZE" NUMBER(12,0) NOT NULL ENABLE,
"NORTH" NUMBER(19,15) NOT NULL ENABLE,
"SOUTH" NUMBER(19,15) NOT NULL ENABLE,
"EAST" NUMBER(19,15) NOT NULL ENABLE,
"WEST" NUMBER(19,15) NOT NULL ENABLE,
"BLOCKMBR" "MDSYS"."SDO_GEOMETRY" ,
"RASTERBLOCK" BLOB,
"INFO_CREATOR" VARCHAR2(100 BYTE) DEFAULT 'novalue' NOT NULL ENABLE,
"INFO_CREATED" TIMESTAMP (6) WITH LOCAL TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL ENABLE,
"INFO_LASTMODIFIER" VARCHAR2(100 CHAR) DEFAULT 'novalue' NOT NULL ENABLE,
"INFO_LASTMODIEFIER" TIMESTAMP (6) WITH LOCAL TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL ENABLE,
CONSTRAINT "NJ_VE_RDT_PK" PRIMARY KEY
("RASTERID"
,"BANDBLOCKNUMBER"
,"PYRAMIDLEVEL"
,"ROWBLOCKNUMBER"
,"COLUMNBLOCKNUMBER"))
PARTITION BY RANGE (WEST) INTERVAL (1)
SUBPARTION BY RANGE (NORTH)
SUBPARTITION TMEPLATE (
SUBPARTITION s0 VALUES LESS THAN (15)
,SUBPARTITION s0 VALUES LESS THAN (5)
(PARTITION p0 VALUES LESS THAN (0));
What is my problem ? My current solution is fully dropping subpartitioning. but thats a cheesy workaround...
ingo
Message was edited by:
Ingo Jannickachso ?!
this works, but even switching the subpartition definitions results in the mentioned error. adding another sub does the same.
my guess is that it is a range by interval issue. i have to figure that out...
Working:
CREATE TABLE "NJ_VEL_RDT"
( "RASTERID" NUMBER NOT NULL ENABLE,
"BANDBLOCKNUMBER" NUMBER NOT NULL ENABLE,
"PYRAMIDLEVEL" NUMBER NOT NULL ENABLE,
"ROWBLOCKNUMBER" NUMBER NOT NULL ENABLE,
"COLUMNBLOCKNUMBER" NUMBER NOT NULL ENABLE,
"FILENAME" VARCHAR2(100 CHAR) NOT NULL ENABLE,
"FILESIZE" NUMBER(12,0) NOT NULL ENABLE,
"NORTH" NUMBER(19,15) NOT NULL ENABLE,
"SOUTH" NUMBER(19,15) NOT NULL ENABLE,
"EAST" NUMBER(19,15) NOT NULL ENABLE,
"WEST" NUMBER(19,15) NOT NULL ENABLE,
"BLOCKMBR" "MDSYS"."SDO_GEOMETRY" ,
"RASTERBLOCK" BLOB,
"INFO_CREATOR" VARCHAR2(100 BYTE) DEFAULT 'novalue' NOT NULL ENABLE,
"INFO_CREATED" TIMESTAMP (6) WITH LOCAL TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL ENABLE,
"INFO_LASTMODIFIER" VARCHAR2(100 CHAR) DEFAULT 'novalue' NOT NULL ENABLE,
"INFO_LASTMODIEFIER" TIMESTAMP (6) WITH LOCAL TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL ENABLE,
CONSTRAINT "NJ_VE_PK" PRIMARY KEY
( "RASTERID",
"BANDBLOCKNUMBER",
"PYRAMIDLEVEL",
"ROWBLOCKNUMBER",
"COLUMNBLOCKNUMBER"))
PARTITION BY RANGE(WEST) INTERVAL (5)
SUBPARTITION BY RANGE(NORTH)
SUBPARTITION TEMPLATE
SUBPARTITION s1 VALUES LESS THAN (65)
,SUBPARTITION s0 VALUES LESS THAN (MAXVALUE)
(PARTITION p0 VALUES LESS THAN (15))
; -
How to check if a constraint existed in the table and drop it?
Hi all,
I want to drop a constraint from a table. I do not know if this constraint already existed in the table. So I want to check if this exists first.
Below is my query:
DECLARE
itemExists NUMBER;
BEGIN
itemExists := 0;
SELECT COUNT(CONSTRAINT_NAME) INTO itemExists
FROM ALL_CONSTRAINTS
WHERE UPPER(CONSTRAINT_NAME) = UPPER('my_constraint');
IF itemExists > 0 THEN
ALTER TABLE my_table DROP CONSTRAINT my_constraint;
END IF;
END;
Here is the error I got when I executed the above query:
ORA-06550: line 11, column 5: PLS-00103: Encountered the symbol "ALTER" when expecting one of the following: ( begin case declare exit for goto if loop mod null pragma raise return select update while with <an identifier> <a double-quoted delimited-identifier> <a bind variable> << continue close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe purge
Please help me with this!
Greatly appreciate!
Khoi LeYes, I also tried to put the pl-sql in the Execute Immediate. However, the error still remains
EXECUTE IMMEDIATE 'DECLARE
itemExists NUMBER;
BEGIN
itemExists := 0;
SELECT COUNT(CONSTRAINT_NAME) INTO itemExists
FROM ALL_CONSTRAINTS
WHERE UPPER(CONSTRAINT_NAME) = UPPER('my_constraint');
IF itemExists > 0 THEN
ALTER TABLE my_table DROP CONSTRAINT my_constraint;
END IF;
END';
I execute the above code via running the batch file.
Here is the error after I ran the batch file:
ORA-06550: line 11, column 5:
PLS-00103: Encountered the symbol "ALTER" when expecting one of the following:
( begin case declare exit for goto if loop mod null pragma
raise return select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
continue close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe purge
The symbol "lock was inserted before "ALTER" to continue.
ORA-06550: line 11, column 53:
PLS-00103: Encountered the symbol "DROP" when expecting one of the following:
. , @ in <an identifier>
<a double-quoted delimited-identifier> partition subpartition
ORA-06512: at line 2117
I can not manually drop it. I need to do this via running an update script file.
Is there a different way to accomplish this?
Thank you very much! -
Moving Subpartitions to a duplicate table in a different schema.
+NOTE: I asked this question on the PL/SQL and SQL forum, but have moved it here as I think it's more appropriate to this forum. I've placed a pointer to this post on the original post.+
Hello Ladies and Gentlemen.
We're currently involved in an exercise at my workplace where we are in the process of attempting to logically organise our data by global region. For information, our production database is currently at version 10.2.0.3 and will shortly be upgraded to 10.2.0.5.
At the moment, all our data 'lives' in the same schema. We are in the process of producing a proof of concept to migrate this data to identically structured (and named) tables in separate database schemas; each schema to represent a global region.
In our current schema, our data is range-partitioned on date, and then list-partitioned on a column named OFFICE. I want to move the OFFICE subpartitions from one schema into an identically named and structured table in a new schema. The tablespace will remain the same for both identically-named tables across both schemas.
Do any of you have an opinion on the best way to do this? Ideally in the new schema, I'd like to create each new table as an empty table with the appropriate range and list partitions defined. I have been doing some testing in our development environment with the EXCHANGE PARTITION statement, but this requires the destination table to be non-partitioned.
I just wondered if, for partition migration across schemas with the table name and tablespace remaining constant, there is an official "best practice" method of accomplishing such a subpartition move neatly, quickly and elegantly?
Any helpful replies welcome.
Cheers.
JamesYou CAN exchange a subpartition into another table using a "temporary" (staging) table as an intermediary.
See :
SQL> drop table part_subpart purge;
Table dropped.
SQL> drop table NEW_part_subpart purge;
Table dropped.
SQL> drop table STG_part_subpart purge;
Table dropped.
SQL>
SQL> create table part_subpart(col_1 number not null, col_2 varchar2(30))
2 partition by range (col_1) subpartition by list (col_2)
3 (
4 partition p_1 values less than (10) (subpartition p_1_s_1 values ('A'), subpartition p_1_s_2 values ('B'), subpartition p_1_s_3 values ('C'))
5 ,
6 partition p_2 values less than (20) (subpartition p_2_s_1 values ('A'), subpartition p_2_s_2 values ('B'), subpartition p_2_s_3 values ('C'))
7 )
8 /
Table created.
SQL>
SQL> create index part_subpart_ndx on part_subpart(col_1) local;
Index created.
SQL>
SQL>
SQL> insert into part_subpart values (1,'A');
1 row created.
SQL> insert into part_subpart values (2,'A');
1 row created.
SQL> insert into part_subpart values (2,'B');
1 row created.
SQL> insert into part_subpart values (2,'B');
1 row created.
SQL> insert into part_subpart values (2,'C');
1 row created.
SQL> insert into part_subpart values (11,'A');
1 row created.
SQL> insert into part_subpart values (11,'C');
1 row created.
SQL>
SQL> commit;
Commit complete.
SQL>
SQL> create table NEW_part_subpart(col_1 number not null, col_2 varchar2(30))
2 partition by range (col_1) subpartition by list (col_2)
3 (
4 partition n_p_1 values less than (10) (subpartition n_p_1_s_1 values ('A'), subpartition n_p_1_s_2 values ('B'), subpartition n_p_1_s_3 values ('C'))
5 ,
6 partition n_p_2 values less than (20) (subpartition n_p_2_s_1 values ('A'), subpartition n_p_2_s_2 values ('B'), subpartition n_p_2_s_3 values ('C'))
7 )
8 /
Table created.
SQL>
SQL> create table STG_part_subpart(col_1 number not null, col_2 varchar2(30))
2 /
Table created.
SQL>
SQL> -- ensure that the Staging table is empty
SQL> truncate table STG_part_subpart;
Table truncated.
SQL> -- exchanging a subpart out of part_subpart
SQL> alter table part_subpart exchange subpartition
2 p_2_s_1 with table STG_part_subpart;
Table altered.
SQL> -- exchanging the subpart into NEW_part_subpart
SQL> alter table NEW_part_subpart exchange subpartition
2 n_p_2_s_1 with table STG_part_subpart;
Table altered.
SQL>
SQL>
SQL> select * from NEW_part_subpart subpartition (n_p_2_s_1);
COL_1 COL_2
11 A
SQL>
SQL> select * from part_subpart subpartition (p_2_s_1);
no rows selected
SQL>I have exchanged subpartition p_2_s_1 out of the table part_subpart into the table NEW_part_subpart -- even with a different name for the subpartition (n_p_2_s_1) if so desired.
NOTE : Since your source and target tables are in different schemas, you will have to move (or copy) the staging table STG_part_subpart from the first schema to the second schema after the first "exchange subpartition" is done. You will have to do this for every subpartition to be exchanged.
Hemant K Chitale
Edited by: Hemant K Chitale on Apr 4, 2011 10:19 AM
Added clarification for cross-schema exchange. -
AVOID Subpartition(list) to be created when Splitting Main Partition(range)
I have created a table structure as below:
CREATE TABLE TEST_SUBPARTITIONS_1
RECORD_ID INTEGER NOT NULL,
SUB_ID VARCHAR2(100),
COBDATE DATE,
DESC VARCHAR2(2000)
PARTITION BY RANGE (COBDATE)
SUBPARTITION BY list(SUB_ID)
PARTITION INITIAL_PARTITION VALUES LESS THAN (TO_DATE(' 2200-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
TABLESPACE TBS_DATA
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE
INITIAL 64K
NEXT 1M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
(SUBPARTITION INITIAL_SUBPARTITION VALUES ('INITIAL_DUMMY_SUB_ID') TABLESPACE TBS_DATA
CREATE UNIQUE INDEX TEST_SUBPARTITIONS_1_PK ON TEST_SUBPARTITIONS_1 (COBDATE, RECORD_ID, SUB_ID) LOCAL;
ALTER TABLE TEST_SUBPARTITIONS_1 ADD CONSTRAINT TEST_SUBPARTITIONS_1_PK PRIMARY KEY (COBDATE, RECORD_ID, SUB_ID);
I am partitioning the table based on range (COBDATE) and subpartitioning based on list (SUB_ID).
The table now is created with initial partitions and initial subpartition.
We are splitting the partitions in our procedure as below
ALTER TABLE TEST_SUBPARTITIONS_1 SPLIT PARTITION
TST_SUB_R21001231 AT (TO_DATE(20130220,'YYYYMMDD') ) INTO
(PARTITION TST_SUB_R20130219 TABLESPACE TBS_DATA, PARTITION TST_SUB_R21001231)
The partition is getting split correctly with new partition as
TST_SUB_R20130219, but the subpartition is also created automatically with some 'SYS' name.
(i.e Name: SYS_SUBP693 , Values: INITIAL_DUMMY_SUB_ID)
This happens after every split of range by COBDATE.
Here it has created as below:
Partition SubPartition
TST_SUB_R21001231 INITIAL_SUBPARTITION
TST_SUB_R20130219 SYS_SUBP693
TST_SUB_R20130220 SYS_SUBP694
TST_SUB_R20130221 SYS_SUBP695
I want to AVOID splitting subpartition when I split the main partition
i.e a SYS subpartition should not be created when I split the partition for COBDATE.
Let me know how do I avoid this in main "alter statement" above?
Any other solution? I do not want to drop the SYS subpartition later, instead want it to avoid creating only when I split the partition.>
I want to AVOID splitting subpartition when I split the main partition
i.e a SYS subpartition should not be created when I split the partition for COBDATE.
Let me know how do I avoid this in main "alter statement" above?
Any other solution? I do not want to drop the SYS subpartition later, instead want it to avoid creating only when I split the partition.
>
The subpartitions aren't being split. Oracle is creating new subpartitions for the new partition. The subpartitions need to exist since that is where the data is stored.
You can avoid the SYS prefix on the name though by using a different naming convention.
See the 'Splitting a *-List Partition' section of the VLDB and Partitioning Guide
http://docs.oracle.com/cd/E11882_01/server.112/e25523/part_admin002.htm#i1008028
>
The ALTER TABLE ... SPLIT PARTITION statement provides no means of specifically naming subpartitions resulting from the split of a partition in a composite partitioned table. However, for those subpartitions in the parent partition with names of the form partition name_subpartition name, the database generates corresponding names in the newly created subpartitions using the new partition names. All other subpartitions are assigned system generated names of the form SYS_SUBPn. System generated names are also assigned for the subpartitions of any partition resulting from the split for which a name is not specified. Unnamed partitions are assigned a system generated partition name of the form SYS_Pn. -
Export/Import subpartition stats
I hope someone can give me a workaround for this, because it's causing our reports to take longer than they should!
Background:
We have some sub-partitioned tables on a 10.2.0.3 database, partitioned daily on the date column, with the subpartitions based on a list of values.
Overnight, various reports are run. Each report loads its data into the table, and then produces a file based on the data that's been loaded for that report. It is not practical (IMO) to analyze the tables after each report has loaded its data, due to other reports loading their data at the same time.
As the amount of data loaded into the tables each night does not vary significantly, we export the stats from a previous partition and import them into the new partition as part of the partition housekeeping job (stats imported from old partition, old partition gets dropped, new partition created with same name as the old one, and stats imported). This is done using dbms_sql.export_table_stats and dbms_sql.import_table_stats.
However, one report which currently loads 43million rows is taking 4.5 hours to run. The size of the load file increases daily, but looking at the history of the report, each relatively small increase causes the report to run a disproportional amount longer (ie. an increase of a similar amount of rows on one night can add twice as much time onto the length of the report than the increase the previous night did).
We've just implemented some changes to improve the buffer sizes, etc, on the database, in a bid to reduce some of the waits, but this has not improved matters much - the report now runs in 4 hours.
We know this report can run faster, because in testing, we saw the report run in 60 minutes! Subsequent investigation shows that this was after the partitions had been analyzed, whereas the slow report ran prior to the partitions being analyzed, despite the stats being there for the partition.
I have now tested the export/import stats process and found that they do not import the stats for the subpartitions. This looks like it is a large part of why the report takes longer before the relevant partitions/subpartitions have been analyzed than it does afterwards.
Does anyone know of anyway that I can export/import the stats at a subpartition level? (I tried putting a subpartition name in the partition parameter, but I just got an error about it being an unknown partition name.)
Any help, ideas or workarounds on this will be gratefully received!*** Duplicate Post - Please Ignore ***
-
Create table with day wise subpartition in 11g
Hi
how to create day wise subpartition & year wise partion in 11gshd wrote:
I have created partition table using non-partiiton structure.
now i m inserting data from non-partition to partition table but i got error
ORA-14400: inserted partition key does not map to any partitionHow you created parittion table?
Hows your non partitioned table looks like and sample data?
How you wish to partition it?
More over you can use DBMS_REDEFINITION. The following privileges must be granted to the user to run DBMS_REDEFINITION: (PRIVILEGES FOR DBMS_REDEFINITION)
ALTER ANY TABLE
CREATE ANY TABLE
DROP ANY TABLE
LOCK ANY TABLE
SELECT ANY TABLE
CREATE ANY INDEX
CREATE ANY TRIGGER
Regards
Girish Sharma -
Drop partition with missing associate Tablespace
Hi All,
Scenario is user accidentally removed datafile using rm command then we dropped that Tablespace using offline drop. we want to drop partition for which TS and datafile both are already offline dropped .
Thanks.>
I tried to exchange partition with another table having same properties of original table. While doing so it prompted below error,
ORA-14292: Partitioning type of table must match subpartitioning type of composite partition
>
Then most likely the table and partition do NOT have the same properties.
If you want to exchange a partition of a table that is subpartitioned then the other table has to be partitioned in the same way that the main table is subpartitioned.
Post the DDL for the main table that shows how it is partitioned/subpartitioned and the DDL for the work table you are trying to use for the exchange.
See my reply Posted: Jan 7, 2013 7:02 PM in this thread for a solution that uses exchange partition is a similar manner
Merge tables -
Drop column from compressed partitioned table
Hi,
DB version is 11.2.02.
We have table which is range partitioned and sub-partitioned by list.
Table is also compressed.
When I try to drop a column, I get error.
CREATE TABLE DWH_REP.P_RATING (
id_source$ NUMBER(38,0) NULL,
time_insert$ DATE ,
time_update$ DATE ,
FLG_CURRENT$ NUMBER(38,0) ,
FLG_CHANGED$ NUMBER(38,0) ,
id_audit$ NUMBER(38,0) ,
ID_DATE_PSTING NUMBER(38,0) ,
partner_rating_id VARCHAR2(256) ,
partner_id VARCHAR2(256) ,
id_partner NUMBER(38,0) ,
rating_system_id VARCHAR2(256) ,
rating_id VARCHAR2(256) ,
date_rating DATE ,
date_follow_up DATE ,
risk_team_id VARCHAR2(256) ,
risk_team_descr VARCHAR2(256) ,
risk_team_changed_id VARCHAR2(256) ,
risk_team_changed_descr VARCHAR2(256) ,
date_risk_team_changed DATE ,
assignment_id VARCHAR2(256) ,
date_assignment DATE ,
date_assignment_confirmed DATE ,
date_assignment_expiration DATE ,
flg_exception VARCHAR2(256) ,
exception_id VARCHAR2(256) ,
date_exception DATE
-- TABLESPACE DWH_REP_DATA
PARTITION BY RANGE (FLG_CURRENT$, ID_DATE_PSTING)
SUBPARTITION BY LIST (ID_SOURCE$)
(PARTITION P_RATING_2010
VALUES LESS THAN (0, 20110101)
SUBPARTITION P_RATING_2010_UCS VALUES (10) TABLESPACE DWH_O_2010_TBS,
SUBPARTITION P_RATING_2010_UCM VALUES (11) TABLESPACE DWH_O_2010_TBS,
-- SUBPARTITION P_RATING_2010_ORBI30 VALUES (30) TABLESPACE DWH_O_2010_TBS,
-- SUBPARTITION P_RATING_2010_ORBI31 VALUES (31) TABLESPACE DWH_O_2010_TBS,
SUBPARTITION P_RATING_2010_CETELEM VALUES (40) TABLESPACE DWH_O_2010_TBS,
-- SUBPARTITION P_RATING_2010_MILES VALUES (60) TABLESPACE DWH_O_2010_TBS,
-- SUBPARTITION P_RATING_2010_BHI VALUES (80) TABLESPACE DWH_O_2010_TBS,
SUBPARTITION P_RATING_2010_DF VALUES (DEFAULT) TABLESPACE DWH_O_2010_TBS),
PARTITION P_RATING_2011
VALUES LESS THAN (0, 20120101)
SUBPARTITION P_RATING_2011_UCS VALUES (10) TABLESPACE DWH_O_2011_TBS,
SUBPARTITION P_RATING_2011_UCM VALUES (11) TABLESPACE DWH_O_2011_TBS,
-- SUBPARTITION P_RATING_2011_ORBI30 VALUES (30) TABLESPACE DWH_O_2011_TBS,
-- SUBPARTITION P_RATING_2011_ORBI31 VALUES (31) TABLESPACE DWH_O_2011_TBS,
SUBPARTITION P_RATING_2011_CETELEM VALUES (40) TABLESPACE DWH_O_2011_TBS,
-- SUBPARTITION P_RATING_2011_MILES VALUES (60) TABLESPACE DWH_O_2011_TBS,
-- SUBPARTITION P_RATING_2011_BHI VALUES (80) TABLESPACE DWH_O_2011_TBS,
SUBPARTITION P_RATING_2011_DF VALUES (DEFAULT) TABLESPACE DWH_O_2011_TBS),
PARTITION P_RATING_current
VALUES LESS THAN (maxvalue, maxvalue)
SUBPARTITION P_RATING_CUR_UCS VALUES (10) TABLESPACE DWH_O_CRT_UCS_TBS,
SUBPARTITION P_RATING_CUR_UCM VALUES (11) TABLESPACE DWH_O_CRT_UPM_TBS,
-- SUBPARTITION P_RATING_CUR_ORBI30 VALUES (30) TABLESPACE DWH_O_CRT_ORBI30_TBS,
-- SUBPARTITION P_RATING_CUR_ORBI31 VALUES (31) TABLESPACE DWH_O_CRT_ORBI31_TBS,
SUBPARTITION P_RATING_CUR_CETELEM VALUES (40) TABLESPACE DWH_O_CRT_CETELEM_TBS,
-- SUBPARTITION P_RATING_CUR_MILES VALUES (60) TABLESPACE DWH_O_CRT_MILES_TBS,
-- SUBPARTITION P_RATING_CUR_BHI VALUES (80) TABLESPACE DWH_O_CRT_BHI_TBS,
SUBPARTITION P_RATING_CUR_DF VALUES (DEFAULT) TABLESPACE DWH_O_CRT_DF_TBS))
ENABLE ROW MOVEMENT
NOLOGGING
COMPRESS
NOCACHE
NOPARALLEL
MONITORING;
ALTER TABLE DWH_REP.P_RATING DROP COLUMN ID_PARTNER;
ORA-39726: unsupported add/drop column operation on compressed tableslittleboy wrote:
Hi,
DB version is 11.2.02.
We have table which is range partitioned and sub-partitioned by list.
Table is also compressed.
When I try to drop a column, I get error.
CREATE TABLE DWH_REP.P_RATING (
id_source$ NUMBER(38,0) NULL,
time_insert$ DATE ,
time_update$ DATE ,
FLG_CURRENT$ NUMBER(38,0) ,
FLG_CHANGED$ NUMBER(38,0) ,
id_audit$ NUMBER(38,0) ,
ID_DATE_PSTING NUMBER(38,0) ,
partner_rating_id VARCHAR2(256) ,
partner_id VARCHAR2(256) ,
id_partner NUMBER(38,0) ,
rating_system_id VARCHAR2(256) ,
rating_id VARCHAR2(256) ,
date_rating DATE ,
date_follow_up DATE ,
risk_team_id VARCHAR2(256) ,
risk_team_descr VARCHAR2(256) ,
risk_team_changed_id VARCHAR2(256) ,
risk_team_changed_descr VARCHAR2(256) ,
date_risk_team_changed DATE ,
assignment_id VARCHAR2(256) ,
date_assignment DATE ,
date_assignment_confirmed DATE ,
date_assignment_expiration DATE ,
flg_exception VARCHAR2(256) ,
exception_id VARCHAR2(256) ,
date_exception DATE
-- TABLESPACE DWH_REP_DATA
PARTITION BY RANGE (FLG_CURRENT$, ID_DATE_PSTING)
SUBPARTITION BY LIST (ID_SOURCE$)
(PARTITION P_RATING_2010
VALUES LESS THAN (0, 20110101)
SUBPARTITION P_RATING_2010_UCS VALUES (10) TABLESPACE DWH_O_2010_TBS,
SUBPARTITION P_RATING_2010_UCM VALUES (11) TABLESPACE DWH_O_2010_TBS,
-- SUBPARTITION P_RATING_2010_ORBI30 VALUES (30) TABLESPACE DWH_O_2010_TBS,
-- SUBPARTITION P_RATING_2010_ORBI31 VALUES (31) TABLESPACE DWH_O_2010_TBS,
SUBPARTITION P_RATING_2010_CETELEM VALUES (40) TABLESPACE DWH_O_2010_TBS,
-- SUBPARTITION P_RATING_2010_MILES VALUES (60) TABLESPACE DWH_O_2010_TBS,
-- SUBPARTITION P_RATING_2010_BHI VALUES (80) TABLESPACE DWH_O_2010_TBS,
SUBPARTITION P_RATING_2010_DF VALUES (DEFAULT) TABLESPACE DWH_O_2010_TBS),
PARTITION P_RATING_2011
VALUES LESS THAN (0, 20120101)
SUBPARTITION P_RATING_2011_UCS VALUES (10) TABLESPACE DWH_O_2011_TBS,
SUBPARTITION P_RATING_2011_UCM VALUES (11) TABLESPACE DWH_O_2011_TBS,
-- SUBPARTITION P_RATING_2011_ORBI30 VALUES (30) TABLESPACE DWH_O_2011_TBS,
-- SUBPARTITION P_RATING_2011_ORBI31 VALUES (31) TABLESPACE DWH_O_2011_TBS,
SUBPARTITION P_RATING_2011_CETELEM VALUES (40) TABLESPACE DWH_O_2011_TBS,
-- SUBPARTITION P_RATING_2011_MILES VALUES (60) TABLESPACE DWH_O_2011_TBS,
-- SUBPARTITION P_RATING_2011_BHI VALUES (80) TABLESPACE DWH_O_2011_TBS,
SUBPARTITION P_RATING_2011_DF VALUES (DEFAULT) TABLESPACE DWH_O_2011_TBS),
PARTITION P_RATING_current
VALUES LESS THAN (maxvalue, maxvalue)
SUBPARTITION P_RATING_CUR_UCS VALUES (10) TABLESPACE DWH_O_CRT_UCS_TBS,
SUBPARTITION P_RATING_CUR_UCM VALUES (11) TABLESPACE DWH_O_CRT_UPM_TBS,
-- SUBPARTITION P_RATING_CUR_ORBI30 VALUES (30) TABLESPACE DWH_O_CRT_ORBI30_TBS,
-- SUBPARTITION P_RATING_CUR_ORBI31 VALUES (31) TABLESPACE DWH_O_CRT_ORBI31_TBS,
SUBPARTITION P_RATING_CUR_CETELEM VALUES (40) TABLESPACE DWH_O_CRT_CETELEM_TBS,
-- SUBPARTITION P_RATING_CUR_MILES VALUES (60) TABLESPACE DWH_O_CRT_MILES_TBS,
-- SUBPARTITION P_RATING_CUR_BHI VALUES (80) TABLESPACE DWH_O_CRT_BHI_TBS,
SUBPARTITION P_RATING_CUR_DF VALUES (DEFAULT) TABLESPACE DWH_O_CRT_DF_TBS))
ENABLE ROW MOVEMENT
NOLOGGING
COMPRESS
NOCACHE
NOPARALLEL
MONITORING;
ALTER TABLE DWH_REP.P_RATING DROP COLUMN ID_PARTNER;
ORA-39726: unsupported add/drop column operation on compressed tables
can you checkwith following?
SQL>alter table t set unused column x;
SQL>alter table t drop unused columns;Tom explains it ->http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:69076630635645 -
Different subpartitioning schemes for mviews and PCT-refresh
It appears that I can have a table RANGE-partitioned by some field (DATE) and LIST-subpartitioned by another field (let's call it subfield2). Then I create materialized view (mview) based on that table, RANGE-partitioned by the same DATE field, but subpartitioned by another field (subfield1, logically parent of subfield2). Then I create another mview, again RANGE-partitioned by the same DATE field, but not subpartitioned at all.
PCT-refresh (dbms_mview.refresh('mview_name', 'P')) works fine, producing correct results. But I wonder if subpartitioning is taken into account when refreshing mviews. My suspicion is that only primary partitioning is taken into account, and primary partitions are refreshed as a whole, even if only one or few subpartitions have been modified in a table. Are my assumptions correct?
Another question - can I preserve partitions in mview if dropping them in underlying table? Table stores raw data, and legacy partitions may be dropped to free up some space. But mviews which store data aggregated on some levels may need to preserve data either longer than in raw table, or forever. I could not find a way of achieving this - when I drop a partition from a table on which mviews are built, and refresh mviews - data from dropped partitions of a table is gone from mviews, even though partitions of mviews are not deleted.It appears that I can have a table RANGE-partitioned by some field (DATE) and LIST-subpartitioned by another field (let's call it subfield2). Then I create materialized view (mview) based on that table, RANGE-partitioned by the same DATE field, but subpartitioned by another field (subfield1, logically parent of subfield2). Then I create another mview, again RANGE-partitioned by the same DATE field, but not subpartitioned at all.
PCT-refresh (dbms_mview.refresh('mview_name', 'P')) works fine, producing correct results. But I wonder if subpartitioning is taken into account when refreshing mviews. My suspicion is that only primary partitioning is taken into account, and primary partitions are refreshed as a whole, even if only one or few subpartitions have been modified in a table. Are my assumptions correct?
Another question - can I preserve partitions in mview if dropping them in underlying table? Table stores raw data, and legacy partitions may be dropped to free up some space. But mviews which store data aggregated on some levels may need to preserve data either longer than in raw table, or forever. I could not find a way of achieving this - when I drop a partition from a table on which mviews are built, and refresh mviews - data from dropped partitions of a table is gone from mviews, even though partitions of mviews are not deleted. -
Using PARTITION FOR/SUBPARTITION FOR syntax to insert
We are trying to use PARTITION FOR syntax (or, better, SUBPARTITION FOR syntax) to insert into a subpartitioned table.
http://docs.oracle.com/cd/E11882_01/server.112/e26088/sql_elements009.htm#i165979
08:26:46 GM_CS_CDR@oradev02> select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for Solaris: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
5 rows selected.This table is has interval partitions on DATA_ORIGIN_ID and list subpartitions on TABLE_NAME.
First, a basic insert without specifying partitions:
08:10:05 GM_CS_CDR@oradev02> insert into key_ids2 (
08:11:51 2 DATA_ORIGIN_ID ,
08:11:51 3 TABLE_NAME ,
08:11:51 4 DUR_UK ,
08:11:51 5 DUR_UK_ID )
08:11:51 6 select
08:11:51 7 12 ,
08:11:51 8 TABLE_NAME ,
08:11:51 9 DUR_UK ,
08:11:51 10 DUR_UK_ID
08:11:51 11 from key_ids where table_name = 'PART'
08:11:51 12 and rownum <= 10;
10 rows created.Verifying SUBPARTITION FOR syntax on a SELECT:
08:19:43 GM_CS_CDR@oradev02>
08:26:45 GM_CS_CDR@oradev02>
08:26:45 GM_CS_CDR@oradev02>
08:26:45 GM_CS_CDR@oradev02>
08:26:45 GM_CS_CDR@oradev02> select count(*) from key_ids2
08:26:45 2 subpartition for(12,'PART');
COUNT(*)
10
1 row selected.But when we add a subpartition specification (to limit the lock to a single subpartition), we get a syntax error:
08:14:57 GM_CS_CDR@oradev02> insert into key_ids2 subpartition for(12,'PART') (
08:14:57 2 DATA_ORIGIN_ID ,
08:14:57 3 TABLE_NAME ,
08:14:57 4 DUR_UK ,
08:14:57 5 DUR_UK_ID )
08:14:57 6 select
08:14:57 7 14 ,
08:14:57 8 TABLE_NAME ,
08:14:57 9 DUR_UK||'!' ,
08:14:57 10 DUR_UK_ID
08:14:57 11 from key_ids
08:14:57 12 where table_name = 'PART'
08:14:57 13 and rownum <= 10;
insert into key_ids2 subpartition for(12,'PART') (
ERROR at line 1:
ORA-14173: illegal subpartition-extended table name syntaxSpecifying at the partition level did not work either:
08:14:58 GM_CS_CDR@oradev02> insert into key_ids2 partition for(14) (
08:15:23 2 DATA_ORIGIN_ID ,
08:15:23 3 TABLE_NAME ,
08:15:23 4 DUR_UK ,
08:15:23 5 DUR_UK_ID )
08:15:23 6 select
08:15:23 7 14 ,
08:15:23 8 TABLE_NAME ,
08:15:23 9 DUR_UK||'!' ,
08:15:23 10 DUR_UK_ID
08:15:23 11 from key_ids
08:15:23 12 where table_name = 'PART'
08:15:23 13 and rownum <= 10;
insert into key_ids2 partition for(14) (
ERROR at line 1:
ORA-14108: illegal partition-extended table name syntaxBut specifying explicit partition and subpartition does work:
08:17:45 GM_CS_CDR@oradev02> insert into key_ids2 partition (SYS_P15127) (
08:18:23 2 DATA_ORIGIN_ID ,
08:18:23 3 TABLE_NAME ,
08:18:23 4 DUR_UK ,
08:18:23 5 DUR_UK_ID )
08:18:23 6 select
08:18:23 7 12 ,
08:18:23 8 TABLE_NAME ,
08:18:23 9 DUR_UK||'!' ,
08:18:23 10 DUR_UK_ID
08:18:23 11 from key_ids
08:18:23 12 where table_name = 'PART'
08:18:23 13 and rownum <= 10;
10 rows created.
08:18:24 GM_CS_CDR@oradev02> insert into key_ids2 subpartition (SYS_SUBP15126) (
08:19:42 2 DATA_ORIGIN_ID ,
08:19:42 3 TABLE_NAME ,
08:19:42 4 DUR_UK ,
08:19:42 5 DUR_UK_ID )
08:19:42 6 select
08:19:42 7 12 ,
08:19:42 8 TABLE_NAME ,
08:19:42 9 DUR_UK||'!#' ,
08:19:42 10 DUR_UK_ID
08:19:42 11 from key_ids
08:19:42 12 where table_name = 'PART'
08:19:42 13 and rownum <= 10;
10 rows created.We have been successful in using the PARTITION FOR syntax for tables that were partitioned but not subpartitioned.
Any ideas?
Thanks,
MikeI've created a simplified script to reproduce our issue. The use of the syntax on an INSERT INTO using VALUES still produces the same error.
Thanks,
Andy
select * from v$version;
create table part_test_tbl
data_origin_id NUMBER not null,
table_name VARCHAR2(30) not null,
dur_uk VARCHAR2(250) not null,
dur_uk_id NUMBER
partition by range (data_origin_id) INTERVAL (1)
subpartition by list (TABLE_NAME)
SUBPARTITION TEMPLATE(
subpartition BLUE values ('BLUE'),
subpartition RED values ('RED'),
subpartition YELLOW values ('YELLOW'),
subpartition GREEN values ('GREEN'),
subpartition ORANGE values ('ORANGE')
(PARTITION DFLT_INTRVL VALUES LESS THAN (0)
subpartition BLUE values ('BLUE'),
subpartition RED values ('RED'),
subpartition YELLOW values ('YELLOW'),
subpartition GREEN values ('GREEN'),
subpartition ORANGE values ('ORANGE')
-- Create/Recreate indexes
create index PART_TEST_TBL_PK on PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
compress 2 local;
create unique index PART_TEST_TBL_UK on PART_TEST_TBL (TABLE_NAME, DUR_UK_ID)
compress 1;
-- Create/Recreate primary, unique and foreign key constraints
alter table PART_TEST_TBL
add constraint PART_TEST_TBL_PK primary key (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK) USING INDEX PART_TEST_TBL_PK;
alter table PART_TEST_TBL
add constraint PART_TEST_TBL_UK unique (TABLE_NAME, DUR_UK_ID) USING INDEX PART_TEST_TBL_UK;
--Add test data
BEGIN
insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
values (0, 'BLUE', '1', 1);
insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
values (0, 'BLUE', '2', 2);
insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
values (0, 'YELLOW', '3', 3);
insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
values (0, 'GREEN', '4', 4);
insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
values (0, 'ORANGE', '5', 5);
insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
values (1, 'BLUE', '6', 6);
insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
values (1, 'BLUE', '7', 7);
insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
values (1, 'YELLOW', '8', 8);
insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
values (1, 'GREEN', '9', 9);
insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
values (1, 'ORANGE', '10', 10);
insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
values (2, 'BLUE', '11', 11);
insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
values (2, 'BLUE', '12', 12);
insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
values (2, 'YELLOW', '13', 13);
insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
values (2, 'GREEN', '14', 14);
insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
values (2, 'ORANGE', '15', 15);
insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
values (10, 'BLUE', '16', 16);
insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
values (10, 'BLUE', '17', 17);
insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
values (10, 'YELLOW', '18', 18);
insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
values (10, 'GREEN', '19', 19);
insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
values (10, 'ORANGE', '20', 20);
COMMIT;
END;
--Validate the subpartition_extended syntax
select count(*) from PART_TEST_TBL subpartition for(10,'BLUE');
--Show subpartition_extended syntax does not work on INSERT INTO
INSERT /*+APPEND */ INTO PART_TEST_TBL SUBPARTITION FOR (10,'BLUE')
(data_origin_id
,table_name
,dur_uk
,dur_uk_id)
VALUES
(10
,'BLUE'
,'16!'
,1016);
--Show subpartition_extended syntax does not work on INSERT INTO
INSERT /*+APPEND */ INTO PART_TEST_TBL SUBPARTITION FOR (10,'BLUE')
(data_origin_id
,table_name
,dur_uk
,dur_uk_id)
SELECT ptt.data_origin_id
,ptt.table_name
,ptt.dur_uk || '!' dur_uk
,ptt.dur_uk_id + 1000 dur_uk_id
FROM PART_TEST_TBL ptt
WHERE ptt.table_name = 'BLUE'
AND ptt.data_origin_id = 10;
DROP TABLE part_test_tbl PURGE;-----
SQL> select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for Solaris: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
SQL> create table part_test_tbl
2 (
3 data_origin_id NUMBER not null,
4 table_name VARCHAR2(30) not null,
5 dur_uk VARCHAR2(250) not null,
6 dur_uk_id NUMBER
7 )
8 partition by range (data_origin_id) INTERVAL (1)
9 subpartition by list (TABLE_NAME)
10 SUBPARTITION TEMPLATE(
11 subpartition BLUE values ('BLUE'),
12 subpartition RED values ('RED'),
13 subpartition YELLOW values ('YELLOW'),
14 subpartition GREEN values ('GREEN'),
15 subpartition ORANGE values ('ORANGE')
16 )
17 (PARTITION DFLT_INTRVL VALUES LESS THAN (0)
18 (
19 subpartition BLUE values ('BLUE'),
20 subpartition RED values ('RED'),
21 subpartition YELLOW values ('YELLOW'),
22 subpartition GREEN values ('GREEN'),
23 subpartition ORANGE values ('ORANGE')
24 )
25 );
Table created
SQL> -- Create/Recreate indexes
SQL> create index PART_TEST_TBL_PK on PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
2 compress 2 local;
Index created
SQL> create unique index PART_TEST_TBL_UK on PART_TEST_TBL (TABLE_NAME, DUR_UK_ID)
2 compress 1;
Index created
SQL> -- Create/Recreate primary, unique and foreign key constraints
SQL> alter table PART_TEST_TBL
2 add constraint PART_TEST_TBL_PK primary key (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK) USING INDEX PART_TEST_TBL_PK;
Table altered
SQL> alter table PART_TEST_TBL
2 add constraint PART_TEST_TBL_UK unique (TABLE_NAME, DUR_UK_ID) USING INDEX PART_TEST_TBL_UK;
Table altered
SQL> --Add test data
SQL> BEGIN
2
3 insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
4 values (0, 'BLUE', '1', 1);
5
6 insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
7 values (0, 'BLUE', '2', 2);
8
9 insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
10 values (0, 'YELLOW', '3', 3);
11
12 insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
13 values (0, 'GREEN', '4', 4);
14
15 insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
16 values (0, 'ORANGE', '5', 5);
17
18 insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
19 values (1, 'BLUE', '6', 6);
20
21 insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
22 values (1, 'BLUE', '7', 7);
23
24 insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
25 values (1, 'YELLOW', '8', 8);
26
27 insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
28 values (1, 'GREEN', '9', 9);
29
30 insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
31 values (1, 'ORANGE', '10', 10);
32
33 insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
34 values (2, 'BLUE', '11', 11);
35
36 insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
37 values (2, 'BLUE', '12', 12);
38
39 insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
40 values (2, 'YELLOW', '13', 13);
41
42 insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
43 values (2, 'GREEN', '14', 14);
44
45 insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
46 values (2, 'ORANGE', '15', 15);
47
48 insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
49 values (10, 'BLUE', '16', 16);
50
51 insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
52 values (10, 'BLUE', '17', 17);
53
54 insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
55 values (10, 'YELLOW', '18', 18);
56
57 insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
58 values (10, 'GREEN', '19', 19);
59
60 insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
61 values (10, 'ORANGE', '20', 20);
62
63 COMMIT;
64 END;
65 /
PL/SQL procedure successfully completed
SQL> --Validate the subpartition_extended syntax
SQL> select count(*) from PART_TEST_TBL subpartition for(10,'BLUE');
COUNT(*)
2
SQL> --Show subpartition_extended syntax does not work on INSERT INTO
SQL> INSERT /*+APPEND */ INTO PART_TEST_TBL SUBPARTITION FOR (10,'BLUE')
2 (data_origin_id
3 ,table_name
4 ,dur_uk
5 ,dur_uk_id)
6 VALUES
7 (10
8 ,'BLUE'
9 ,'16!'
10 ,1016);
INSERT /*+APPEND */ INTO PART_TEST_TBL SUBPARTITION FOR (10,'BLUE')
(data_origin_id
,table_name
,dur_uk
,dur_uk_id)
VALUES
(10
,'BLUE'
,'16!'
,1016)
ORA-14173: illegal subpartition-extended table name syntax
SQL> --Show subpartition_extended syntax does not work on INSERT INTO
SQL> INSERT /*+APPEND */ INTO PART_TEST_TBL SUBPARTITION FOR (10,'BLUE')
2 (data_origin_id
3 ,table_name
4 ,dur_uk
5 ,dur_uk_id)
6 SELECT ptt.data_origin_id
7 ,ptt.table_name
8 ,ptt.dur_uk || '!' dur_uk
9 ,ptt.dur_uk_id + 1000 dur_uk_id
10 FROM PART_TEST_TBL ptt
11 WHERE ptt.table_name = 'BLUE'
12 AND ptt.data_origin_id = 10;
INSERT /*+APPEND */ INTO PART_TEST_TBL SUBPARTITION FOR (10,'BLUE')
(data_origin_id
,table_name
,dur_uk
,dur_uk_id)
SELECT ptt.data_origin_id
,ptt.table_name
,ptt.dur_uk || '!' dur_uk
,ptt.dur_uk_id + 1000 dur_uk_id
FROM PART_TEST_TBL ptt
WHERE ptt.table_name = 'BLUE'
AND ptt.data_origin_id = 10
ORA-14173: illegal subpartition-extended table name syntax
SQL> DROP TABLE part_test_tbl PURGE;
Table dropped
SQL> -
Subpartitioning a partitioned table
Hi Experts,
I would like to sub-partition few of the hand picked partitions of a partitioned-table. Is it possible???
Below is my example partition table:
drop table part_tab purge;
create table part_tab (id number, name clob, dt date)
partition by range (dt) (
partition p1 values less than (to_date('01-2-2012', 'dd-mm-yyyy')),
partition p2 values less than (to_date('01-3-2012', 'dd-mm-yyyy')),
partition p3 values less than (to_date('01-4-2012', 'dd-mm-yyyy')),
partition p4 values less than (to_date('01-5-2012', 'dd-mm-yyyy')),
partition p5 values less than (to_date('01-6-2012', 'dd-mm-yyyy')),
partition p6 values less than (to_date('01-7-2012', 'dd-mm-yyyy')));
insert into part_tab select level, 'level-' || level, to_date( to_char(mod(level,25) + 1) || '-01-2012', 'dd-mm-yyyy') from dual connect by level < 100;
insert into part_tab select level, 'level-' || level, to_date( to_char(mod(level,25) + 1) || '-02-2012', 'dd-mm-yyyy') from dual connect by level < 100;
insert into part_tab select level, 'level-' || level, to_date( to_char(mod(level,25) + 1) || '-03-2012', 'dd-mm-yyyy') from dual connect by level < 100;
insert into part_tab select level, 'level-' || level, to_date( to_char(mod(level,25) + 1) || '-04-2012', 'dd-mm-yyyy') from dual connect by level < 100;
insert into part_tab select level, 'level-' || level, to_date( to_char(mod(level,25) + 1) || '-05-2012', 'dd-mm-yyyy') from dual connect by level < 100;
insert into part_tab select level, 'level-' || level, to_date( to_char(mod(level,25) + 1) || '-06-2012', 'dd-mm-yyyy') from dual connect by level < 100;
commit;
create index it_g_id on part_tab(id);
create index it_p_dt on part_tab(dt) local;
select index_name, status from user_indexes where table_name = 'PART_TAB';
select partition_name, status from user_ind_partitions where index_name in (select index_name from user_indexes where table_name = 'PART_TAB');Is it possible to sub-partition only partition p4 & p6?
Thanks for your time.
- P>
I would like to sub-partition few of the hand picked partitions of a partitioned-table. Is it possible???
>
Yes and No - with a (possibly complex) explanation
No - it is not possible to create a subpartitioned table that does not have at least ONE subpartition for each partition. This wouldn't make sense anyway - if there is no subpartition for data to go to there is no point in having the partition at all so just don't create that partition.
Yes - it is possible to create custom sub-partitions for your hand-picked partitions. But the other partitions will still have at least one subpartition. If you don't create a subpartition template then Oracle will create a DEFAULT subpartition for them with a system generated name.
If you do create a subpartition template then it will be used for all partitions for which you do not specify custom subpartitioning.
Here is sample DDL based on yours
drop table part_tab1 cascade constraints
create table part_tab1 (id number, name clob, dt date)
partition by range (dt)
subpartition by list(id)
SUBPARTITION TEMPLATE(
subpartition TEMP_2_AND_3 values (2, 3),
subpartition TEMP_DEFAULT values (DEFAULT)
( partition p1 values less than (to_date('01-2-2012', 'dd-mm-yyyy')),
partition p2 values less than (to_date('01-3-2012', 'dd-mm-yyyy')),
partition p3 values less than (to_date('01-4-2012', 'dd-mm-yyyy')),
partition p4 values less than (to_date('01-5-2012', 'dd-mm-yyyy'))
subpartition P4_1_2_3 values (1, 2, 3),
subpartition P4_4_5_6 values (4, 5, 6),
subpartition P4_DEFAULT values (DEFAULT)
partition p5 values less than (to_date('01-6-2012', 'dd-mm-yyyy')),
partition p6 values less than (to_date('01-7-2012', 'dd-mm-yyyy'))
subpartition P6_7_8_9 values (7, 8, 9),
subpartition P6_DEFAULT values (DEFAULT)
)Note that custom subpartitioning has been specified for partitions p4 and p6 the subpartitioning is different for those two partitions.
In this example I have also specified DEFAULT subpartitions for P4, P6 and the subpartition template so that all subpartition data has somewhere to go.
Any data that does not map to one of the partitions will raise an exception. For example
(INSERT into part_tab1 values (1, 'abc', to_date('07-7-2012', 'dd-mm-yyyy') - 1/24)
ORA-14400: inserted partition key does not map to any partitionTo summarize
1. A subpartitioned table will ALWAYS have at least one subpartition for each partition
2. You can specify custom subpartitioning for any partition that is predefined (i.e. not for INTERVAL partitions).
3. The custom subpartitioning can be different for each partition
4. You can prevent inserting of data into the table by NOT providing a DEFAULT partition (as in your example). Attempts to insert such data will result in an ORA-14400 exception
5. You can also effectively prevent insertion into a partition by defining a subpartition (custom or DEFAULT) for a data value that will never exist in your data. No point in doing this since if no data can be inserted into the partition why have the partition to begin with? -
Hello,
Can someone please tell me what are the commands to add subpartitions to this table:
PARTITION BY LIST (DB_ACTN)
SUBPARTITION BY RANGE (ROW_EFF_DT)
CREATE TABLE GSDBA.t1
(c1 DATE,
c2 INTEGER,
c3 CHAR(1),
c4 CHAR(1)
PARTITION BY LIST (c3)
SUBPARTITION BY RANGE (c1)
SUBPARTITION TEMPLATE
(SUBPARTITION OCT_31_2010 VALUES LESS THAN (TO_DATE(' 2010-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
SUBPARTITION NOV_01_2010 VALUES LESS THAN (TO_DATE(' 2010-11-02 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
SUBPARTITION NOV_02_2010 VALUES LESS THAN (TO_DATE(' 2010-11-03 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
SUBPARTITION FUTURE VALUES LESS THAN (MAXVALUE)
PARTITION R VALUES ('R')
( SUBPARTITION R_OCT_31_2010 VALUES LESS THAN (TO_DATE(' 2010-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
SUBPARTITION R_NOV_01_2010 VALUES LESS THAN (TO_DATE(' 2010-11-02 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
SUBPARTITION R_NOV_02_2010 VALUES LESS THAN (TO_DATE(' 2010-11-03 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
SUBPARTITION R_FUTURE VALUES LESS THAN (MAXVALUE) ),
PARTITION P VALUES ('P')
( SUBPARTITION P_OCT_31_2010 VALUES LESS THAN (TO_DATE(' 2010-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
SUBPARTITION P_NOV_01_2010 VALUES LESS THAN (TO_DATE(' 2010-11-02 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
SUBPARTITION P_NOV_02_2010 VALUES LESS THAN (TO_DATE(' 2010-11-03 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
SUBPARTITION P_FUTURE VALUES LESS THAN (MAXVALUE) ))
I need for example to add a nov 3rd and drop oct31 for all the partitions. Do I have to add them to each partition or can I execute the commands at the table level?
Thank you,K, I found it...
alter table t1 split subpartition P_NOV_02_2010 AT (TO_DATE(' 2010-11-02 12:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
INTO
(subpartition P_NOV_02_2010, subpartition P_NOV1_02_2010);
Maybe you are looking for
-
Why can't I download Adobe Flash Drive on my I-Pad2?
I have tried watching several different video's on-line and am told on all different web sites to download Adobe Flash Reader, when I try to download it a new screen comes up saying "sorry, you cannot download this with this device". What is that abo
-
I've have burned over 100 CDs with my Dell desktop over the last 3 years, but the other day i got a message 'CD disc unable to burn (error 400)'. I don't know what caused it to suddenly stop working. Basically, I selected the play list and told it to
-
Strange error when processing form
Hi, I am getting an error saying "Statement did not generate a result set." when i try to process a textarea form field. code to process textarea is: <cfquery datasource="DMDs"> UPDATE utbl_ContentDetail SET ContentDetail= <cfif isdefined("FORM.Conte
-
Please help creating data model where query has & in select
Below is the actual code of the part of select having a problem. When I had '&' instead of chr(36), a window opens up saying 'Please enter values for lexical references in sql then has *&' and empty box and check box then flex field. So I replaced '&
-
Etude - migrating Solaris 8 to Solaris 10
Hello, I'm looking for some help from someone that has experience with Etude. I have an application that's running on Solaris 8 - I'm looking into porting this application onto Solaris 10 using Etude. My application however has a kernel module - and