Dropping interval partitions
One of the nice Oracle11g new features is interval partitioning which is an extension to range partitioning. The advantage of interval partitioning over range partitioning is that new partitions are created automatically when new rows are inserted which don’t belong in an existing partition.
The question, however, is how to get rid of old partitions? This isn’t as straightforward looks like we need to check transition point...
1. Can anyone explain it more abt the transition point?
2. Also can we drop the old partitions without application down time?
3. what are better approaches to avoid application downtime?
4. Wat happens if the DB receives a query(which includes records in the partition which it is dropping) during partition drop operation ?
hi,
1. Can anyone explain it more abt the transition point?The boundary between the highest range partition and the lowest interval partition is known as the transition point. Partitions above the transition point are created by Oracle automatically
2. Also can we drop the old partitions without application down time?
4. Wat happens if the DB receives a query(which includes records in the partition which it is dropping) during partition drop operation ?AFAIK, It depends onthe the application and which partitions does it required else you can drop the partitions. It would be similar to the data with in table which updated across and in parallell other sessions are queried the same segment, serialization comes into the place and unavailabilty of data would return - based on commit/rollback issued by user.
- Pavan kumar N
Similar Messages
-
Hi,
Using Oracle 11.20.3
We wish to have a range-hash composite partitioned table, one partition for each month.
However, want to esnure are always a partition tehrfore would like to use range interval partitioning.
Have a few questions, if have partition say 201301 to 201312 but get somew rosw which have value in date in June 2014 would it create
a new partition for each month i.e 201401, 201402 etc or just one for 201406?
Wanyt esnure system can cope automatically with following scenario
Daty1 have partitions 201301 to 201312
Day2 get record for 201406 (June 2014)
Day 3 get record for 201403 (March 2014)
We have no control of the range of dates we could get but don't want tpo have to manually create partitions fro all tehse dates in advance - want system to handled it automatically.
Also can you simply rename the system generated partition names to something more meaningful later.>
Using Oracle 11.20.3
We wish to have a range-hash composite partitioned table, one partition for each month.
However, want to esnure are always a partition tehrfore would like to use range interval partitioning.
Have a few questions, if have partition say 201301 to 201312 but get somew rosw which have value in date in June 2014 would it create
a new partition for each month i.e 201401, 201402 etc or just one for 201406?
Wanyt esnure system can cope automatically with following scenario
Daty1 have partitions 201301 to 201312
Day2 get record for 201406 (June 2014)
Day 3 get record for 201403 (March 2014)
We have no control of the range of dates we could get but don't want tpo have to manually create partitions fro all tehse dates in advance - want system to handled it automatically.
>
Do NOT be afraid of breaking Oracle by actually trying things yourself.
DROP TABLE emp_part
CREATE TABLE emp_part (empno number(4), ename varchar2(10),
deptno number(2), created_date DATE default sysdate)
partition by range (created_date)
SUBPARTITION BY HASH(deptno) subpartitions 4
( partition p_prior_to_2014 values less than (to_date('01-01-2014', 'mm-dd-yyyy')));Add some data for 2014 and see for yourself what happens.
>
Also can you simply rename the system generated partition names to something more meaningful later.
>
Yes - assuming you mean more meaninful to a human. Oracle doesn't care what the name is.
And you can just as easily manipulate the partition (delete, insert, drop truncate) regardless of the name since you don't need to use the name to do those things.
You either know the date for the partition you want to work with or you don't. If you know then just tell Oracle and it will work with the correct partition. If you don't believe me try it with the sample code I gave you. Add some data to get a couple of interval partitions created and then drop one of them using Oracle's extended partition syntax. See this example in the 'Dropping Interval Partitions in the VLDB and Partitioning Guide
http://docs.oracle.com/cd/B28359_01/server.111/b32024/part_admin.htm#i1007479
>
The following example drops the September 2007 interval partition from the sales table. There are only local indexes so no indexes will be invalidated.
ALTER TABLE sales DROP PARTITION FOR(TO_DATE('01-SEP-2007','dd-MON-yyyy'));
>
That code doesn't require the partition name. You just need to specify a date that falls IN the partition that you want to drop. You have to do that whether you know the name of the partition or not. Don't 'gunk up' your system with code to rename things unless there is some real need to. -
Possible to use interval partitions to drop old partitions?
Interval partitions can add new partitions and I can do a range by date. This is helpful. However, lets say I have alot of tables in my database and I need to keep data for different lengths of time in different tables. Can I set something in the intervals to drop older partitions?
I don't think I can, but I thought I would ask. I can do this with code. However, if oracle does it for me, I don't want to do it myself.Can not be done but you can use the HIGH_VALUE column, or the PARTITION_POSITION columns to make decisions.
Just remember that you can never drop the root partition so build the initial partition such that it is very small and not used. -
GG replication for interval partitioned tables while issuing drop partition command
Hi all, we have golden gate replication between two databses 1 and 2. table A in 1 and 2 is interval partitioned but the partition names are different. whats the best way to achieve GG replication using drop partition. We want to drop partition automatically in DB 2 if done in DB 1.
Hi,
In this scenario ypu would better to drop manually on both the database, especially for drop you could filter based on operation type and do it manually. -
Creating DOMAIN INDEX (SPATIAL) on INTERVAL PARTITIONING
Hi !
I hava a problem, and I hope someone can help me!
Two questions are asked below:
1. Main question: HOW CAN I SOLVE THIS PROBLEM, ARE THERE OTHER WAYS DOING THE SAME JOB (MAYBE FASTER) ?
2. Additionally: Is there a way to accelerate the deletion process
Step 1: Creating the table For Information how I create the table:
CREATE TABLE LOC_EXAMPLE
COLUMN1 NUMBER
COLUMN2 NUMBER
COLUMN3 NUMBER
COLUMN4 NUMBER
START_TIME TIMESTAMP
GEOLOC MDSYS.SDO_GEOMETRY,
TABLESPACE DB_DATA
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
BUFFER_POOL DEFAULT
NOLOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING
PARTITION BY RANGE (START_TIME)
INTERVAL (NUMTODSINTERVAL(1,'DAY'))
PARTITION PART_LOC_EXAMPLE VALUES LESS THAN (TO_DATE('01-01-2008','dd-MM-yyyy'))
ALTER TABLE LOC_EXAMPLE
ADD CONSTRAINT PK_LOC_EXAMPLE PRIMARY KEY (COLUMN2,COLUMN4)
DELETE FROM USER_SDO_GEOM_METADATA VALUE WHERE TABLE_NAME = 'LOC_EXAMPLE'
INSERT INTO USER_SDO_GEOM_METADATA VALUES ('LOC_EXAMPLE','GEOLOC', MDSYS.SDO_DIM_ARRAY( MDSYS.SDO_DIM_ELEMENT('X',-180,180,0.001111949), MDSYS.SDO_DIM_ELEMENT('Y',-90,90,0.001111949) ), 8307)
STEP 2: I TRY TO CREATE SPATIAL INDEX (ITS A DOMAIN INDEX IF I'M NOT WRONG) ON PARTITIONED TABLE
(PARTITIONED TABLE is an extension of range partitioning)
CREATE INDEX LOC_EXAMPLE_idx ON LOC_EXAMPLE'(GEOLOC)
INDEXTYPE IS MDSYS.SPATIAL_INDEX LOCAL;
THE SECOND STEP IS NOT POSSIBLE AS THE ORACLE DOCUMENTATION SAYS:
When using interval partitioning, consider the following restrictions:
-You can only specify one partitioning key column, and it must be of NUMBER or DATE type.
-Interval partitioning is not supported for index-organized tables.
-You cannot create a domain index on an interval-partitioned table.
1) I THINK IT IS IMPOSSIBLE FOR ME TO PASS ON INTERVAL PARTITIONING (AMOUNT OF DATA IS REALY BIG).
This partitioning is also used to delete datas from database once a mounth (scheduled on the basis of the partitions).
Is there a way to accelerate the deletion process?
2) I NEED A SPATIAL INDEX! NO WAY TO PASS ON IT!
HOW CAN I SOLVE THIS PROBLEM, ARE THERE OTHER WAYS DOING THE SAME JOB (MAYBE FASTER) ?
Why is it not possible to create a domain index on interval partitioning, any reason?
Will this be possible anytime?
I would be grateful to read any advise ...!
Thanking you in anticipation,
AliIs it possible to just use a normal range-partitioned table?
CREATE TABLE LOC_EXAMPLE
START_TIME TIMESTAMP
GEOLOC MDSYS.SDO_GEOMETRY,
PARTITION BY RANGE (START_TIME)
PARTITION P1 VALUES LESS THAN (TO_DATE('01-01-2008','dd-MM-yyyy'))
alter table loc_example add partition p2 VALUES LESS THAN (TO_DATE('02-01-2008','dd-MM-yyyy'));
alter table loc_example drop partition p1;
I understand it is not as perfect as interval partitioning, since
you have to drop an old partition/add a new one either manually
or by some script. But you should be able to create a spatial domain index
on it. -
Primary Key Causing Problem in Interval Partition Exchange
DB : 11.2.0.2
OS : AIX 6.1
I am getting the problem while exchanging data with interval partitioned table. I have a interval partitioned table and a normal staging table having data to be uploaded.
Following are the steps i am doing.
SQL> CREATE TABLE DEMO_INTERVAL_DATA_LOAD (
ROLL_NUM NUMBER(10),
CLASS_ID NUMBER(2),
ADMISSION_DATE DATE,
TOTAL_FEE NUMBER(4),
COURSE_ID NUMBER(4))
PARTITION BY RANGE (ADMISSION_DATE)
INTERVAL (NUMTOYMINTERVAL(3,'MONTH'))
( PARTITION QUAT_1_2012 VALUES LESS THAN (TO_DATE('01-APR-2012','DD-MON-YYYY')),
PARTITION QUAT_2_2012 VALUES LESS THAN (TO_DATE('01-JUL-2012','DD-MON-YYYY')),
PARTITION QUAT_3_2012 VALUES LESS THAN (TO_DATE('01-OCT-2012','DD-MON-YYYY')),
PARTITION QUAT_4_2012 VALUES LESS THAN (TO_DATE('01-JAN-2013','DD-MON-YYYY')));
Table created.
SQL> ALTER TABLE DEMO_INTERVAL_DATA_LOAD ADD CONSTRAINT IDX_DEMO_ROLL PRIMARY KEY (ROLL_NUM);
Table altered.
SQL> SELECT TABLE_OWNER,
TABLE_NAME,
COMPOSITE,
PARTITION_NAME,
PARTITION_POSITION,
TABLESPACE_NAME,
LAST_ANALYZED
FROM DBA_TAB_PARTITIONS
WHERE TABLE_OWNER='SCOTT'
AND TABLE_NAME='DEMO_INTERVAL_DATA_LOAD'
ORDER BY PARTITION_POSITION;
TABLE_OWNER TABLE_NAME COM PARTITION_NAME PARTITION_POSITION TABLESPACE_NAME LAST_ANAL
SCOTT DEMO_INTERVAL_DATA_LOAD NO QUAT_1_2012 1 USERS
SCOTT DEMO_INTERVAL_DATA_LOAD NO QUAT_2_2012 2 USERS
SCOTT DEMO_INTERVAL_DATA_LOAD NO QUAT_3_2012 3 USERS
SCOTT DEMO_INTERVAL_DATA_LOAD NO QUAT_4_2012 4 USERS
SQL> INSERT INTO DEMO_INTERVAL_DATA_LOAD VALUES (10,1,'12-MAR-2012',1000,90);
1 row created.
SQL> INSERT INTO DEMO_INTERVAL_DATA_LOAD VALUES (11,5,'01-JUN-2012',5000,80);
1 row created.
SQL> INSERT INTO DEMO_INTERVAL_DATA_LOAD VALUES (12,9,'12-SEP-2012',4000,20);
1 row created.
SQL> INSERT INTO DEMO_INTERVAL_DATA_LOAD VALUES (13,7,'29-DEC-2012',7000,10);
1 row created.
SQL> INSERT INTO DEMO_INTERVAL_DATA_LOAD VALUES (14,8,'21-JAN-2013',2000,50); ---- This row will create a new interval partition in table.
1 row created.
SQL> commit;
SQL> SELECT TABLE_OWNER,
TABLE_NAME,
COMPOSITE,
PARTITION_NAME,
PARTITION_POSITION,
TABLESPACE_NAME,
LAST_ANALYZED
FROM DBA_TAB_PARTITIONS
WHERE TABLE_OWNER='SCOTT'
AND TABLE_NAME='DEMO_INTERVAL_DATA_LOAD'
ORDER BY PARTITION_POSITION;
TABLE_OWNER TABLE_NAME COM PARTITION_NAME PARTITION_POSITION TABLESPACE_NAME LAST_ANAL
SCOTT DEMO_INTERVAL_DATA_LOAD NO QUAT_1_2012 1 USERS
SCOTT DEMO_INTERVAL_DATA_LOAD NO QUAT_2_2012 2 USERS
SCOTT DEMO_INTERVAL_DATA_LOAD NO QUAT_3_2012 3 USERS
SCOTT DEMO_INTERVAL_DATA_LOAD NO QUAT_4_2012 4 USERS
SCOTT DEMO_INTERVAL_DATA_LOAD NO SYS_P98 5 USERS
SYS_P98 partition is added to table automatically.
SQL> CREATE TABLE DEMO_INTERVAL_DATA_LOAD_Y (
ROLL_NUM NUMBER(10),
CLASS_ID NUMBER(2),
ADMISSION_DATE DATE,
TOTAL_FEE NUMBER(4),
COURSE_ID NUMBER(4));
Table created.
SQL> INSERT INTO DEMO_INTERVAL_DATA_LOAD_Y VALUES (30,3,'21-MAY-2013',2000,12);
1 row created.
SQL> commit;
Commit complete.
Since, i need a partition in DEMO_INTERVAL_DATA_LOAD table, which can be used in partition exchange, so i create a new partition as below:
SQL> LOCK TABLE DEMO_INTERVAL_DATA_LOAD PARTITION FOR (TO_DATE('01-APR-2013','DD-MON-YYYY')) IN SHARE MODE;
Table(s) Locked.
SQL> SELECT TABLE_OWNER,
TABLE_NAME,
COMPOSITE,
PARTITION_NAME,
PARTITION_POSITION,
TABLESPACE_NAME,
LAST_ANALYZED
FROM DBA_TAB_PARTITIONS
WHERE TABLE_OWNER='SCOTT'
AND TABLE_NAME='DEMO_INTERVAL_DATA_LOAD'
ORDER BY PARTITION_POSITION;
TABLE_OWNER TABLE_NAME COM PARTITION_NAME PARTITION_POSITION TABLESPACE_NAME LAST_ANAL
SCOTT DEMO_INTERVAL_DATA_LOAD NO QUAT_1_2012 1 USERS
SCOTT DEMO_INTERVAL_DATA_LOAD NO QUAT_2_2012 2 USERS
SCOTT DEMO_INTERVAL_DATA_LOAD NO QUAT_3_2012 3 USERS
SCOTT DEMO_INTERVAL_DATA_LOAD NO QUAT_4_2012 4 USERS
SCOTT DEMO_INTERVAL_DATA_LOAD NO SYS_P98 5 USERS
SCOTT DEMO_INTERVAL_DATA_LOAD NO SYS_P102 6 USERS
SQL> ALTER TABLE DEMO_INTERVAL_DATA_LOAD
EXCHANGE PARTITION SYS_P102
WITH TABLE DEMO_INTERVAL_DATA_LOAD_Y
INCLUDING INDEXES
WITH VALIDATION;
ALTER TABLE DEMO_INTERVAL_DATA_LOAD
ERROR at line 1:
ORA-14097: column type or size mismatch in ALTER TABLE EXCHANGE PARTITIONNow, if i disable/drop the primary key constraint, it works without any problem.
SQL> alter table DEMO_INTERVAL_DATA_LOAD disable constraint IDX_DEMO_ROLL;
Table altered.
SQL> alter table DEMO_INTERVAL_DATA_LOAD drop constraint IDX_DEMO_ROLL;
Table altered.
SQL> ALTER TABLE DEMO_INTERVAL_DATA_LOAD
EXCHANGE PARTITION SYS_P102
WITH TABLE DEMO_INTERVAL_DATA_LOAD_Y
INCLUDING INDEXES
WITH VALIDATION;
Table altered.
SQL> select * from DEMO_INTERVAL_DATA_LOAD partition (SYS_P102);
ROLL_NUM CLASS_ID ADMISSION TOTAL_FEE COURSE_ID
30 3 21-MAY-13 2000 12
SQL> select * from DEMO_INTERVAL_DATA_LOAD_Y;
no rows selectedPlease suggest.First, thanks for posting the code that lets us reproduce your test. That is essential for issues like this.
Because the primary key is global you will not be able to use
INCLUDING INDEXES
WITH VALIDATION;And you will need to add the primary key to the temp table
ALTER TABLE DEMO_INTERVAL_DATA_LOAD_Y ADD CONSTRAINT IDX_DEMO_ROLL_Y PRIMARY KEY (ROLL_NUM);The the exchange will work. You will need to rebuild the primary key after the exchange. -
Interval Partition naming Issue (Oracle 11g R2 )
I need help on identifying latest partition:
I am using Interval Partition for my table,which creates partition every month end based on inserted data.
When oracle creates partition assigning its own name but users have automated reports using partition names like Table_name_YYYYMM.
I tested following ways to identify partition then renamed,worked fine but in long run do i get any problems ?
or any other way to identify the latest partition ?
1)Using max partition position :
select partition_name from dba_tab_partitions a where partition_position = (select max(partition_position)
from user_tab_partitions b where a.table_name=b.table_name
and b.table_name = 'INTRVL_PARTITION');
2)Using Sub Object max creation date :
SELECT SUBOBJECT_NAME FROM dba_objects
WHERE OBJECT_TYPE='TABLE PARTITION'
AND OWNER='ABCD'
AND OBJECT_NAME='INTRVL_PARTITION'
AND CREATED=(SELECt MAX(CREATED) FROM DBA_OBJECTS
WHERE OBJECT_TYPE='TABLE PARTITION'
AND OWNER='ABCD'
AND OBJECT_NAME='INTRVL_PARTITION');
Thanks in advance .
Edited by: user607128 on Mar 2, 2012 7:09 AMYour initial question said you were already using interval partitioning.
>
I am using Interval Partition for my table
now users asking to convert Range to Interval Partition and keeping existing partitions same name.
>
So is your issue that you want to use interval partitining for a table now is now using range partitioning? Why are your users driving this change? That should be a decision made by the DBA and technical management since the difference is mainly on of management.
Though there is one BIG difference that is data related. With interval partitioning if data (even erroneous data) is inserted for a partition that does not exist Oracle will create one. So if you have an insert statement that inserts 12 records for the year '2038' you will get 12 new partitions even though the data may be bogus.
Now your management problem is detecting the problem, deleting the data (or fixing the date to move it to the right partition) and then dropping the partitions and storage.
With 'interval' partitioning you had better be absolutely sure your data is clean in terms of the partitioning key values.
That said, you can use table redefinition or just create a new interval partitioned table and do partition exchanges with the existing partitions to move the data. -
Hi everyone,
I've got a question about interval partitioning. I've got a fact table, W_GL_BALANCE_F that is fairly massive and I want to use interval partitioning on the BALANCE_DT_WID field. The values in the field are of the form YYYYMMDD || '000', i.e. 20100820000 would be today, 20100821000 would be tomorrow, etc.
I create the table with interval partitioning with an interval of 1000, and then when I go to insert the data, I get the error "Partition does not exist". I was a little confused because I thought interval partitions created partitions for any new value.
I ran some tests on a test table part_test(part_key number) partition range interval (1) ( partition "zero" less than 1). Then I inserted a few test records
INSERT INTO part_test (part_key) values (1);
INSERT INTO part_test (part_key) values (2);
INSERT INTO part_test (part_key) values (10);
INSERT INTO part_test (part_key) values (1000000); --- This causes error "Partition does not exist"
Obviously there are some additional rules to go along with using the intervals. I was under the impression that it would just create a range for any new value but it seems more complicated than that.
Can someone explain to me why the final record isn't able to have a new partition created for it?
I apologize if this is a dumb question, but I'm a little new to the different partitioning options.
Best regards and thanks for the help!
-JoeJoe Bertram wrote:
Hi Tubby,
Just to give you a little more background, I am working with the Oracle BI Applications prepackaged data warehouse and ETLs. Because it's all prepackaged ETLs, I don't have too much flexibility to change the data being loaded, otherwise, I totally agree that using this date format is kind of strange. Thanks for the information, helps to know :)
Joe Bertram wrote:
I looked at other fields on the table for a potential partition key, and this field was the only one that was remotely uniformly distributed. That really isn't the first consideration you should have for partitioning. What are you trying to accomplish with partitioning? Are you looking to make data archival easier (dropping old partitions is the easiest way to go), or are you looking to enhance querying? Partitioning is a tool you implement for a given purpose ... so what's yours?
Joe Bertram wrote:>
You are correct, my test case was a little simplistic. I went back to the data the see why your case succeeded and mine failed. It turns out I missed one part in the date format. In addition to the date format as I laid it out, they also append the calendar ID which refers to the fiscal calender to which the date belongs. the actual format is <4-digit-cal_id>YYYYMMDD<000> i.e. 100120100820000 is today on calendar 1001, but there could also be a calendar 1007 which could have today's date i.e. 100720100820000.
drop table part_test;
create table part_test
part_key number
partition by range (part_key)
interval (1000)
partition zero_1 values less than (100120100820000)
INSERT INTO part_test (part_key) values (100120100820000);
INSERT INTO part_test (part_key) values (100720100820000); -- same day on calendar 1007, causes an errorIt pretty much seems to me that there would be too many potential partitions, so the DB gives up. Is that correct?That indeed seems to be the case, you could perhaps raise a service request with Oracle, but i'm not sure how eager they'd be to enhance the interval partitioning for this case. This data doesn't seem like it would be a good candidate for range partitioning. Again, we need to know what you're goal is from partitioning.
If housekeeping is paramount (keeping X days of data and purging old data) then i would suggest the following.
create table part_test
part_key number,
magic_column generated always as ( to_date(substr (part_key, 5, 8), 'yyyymmdd') ) virtual
partition by range (magic_column)
INTERVAL ( INTERVAL '1' DAY)
partition zero_1 values less than ( to_date('20100820', 'yyyymmdd') )
);Partitioning by a virtual column, the date in this case.
It's possibly you have a more logical key to partition off of, but a RANGE partition scheme on your part_key doesn't sound good at all. -
Droping Partition Dynamically in Interval Partitioning
Hi All,
I have created an Interval Partition Table as show below, Is their any way, i can drop the partition dynamically when i truncate the table as oracle creates them with system generated name? Instead Alter table drop partition !
Create Table Script :
CREATE TABLE TBL_EMP_SALES
EMP_ID NUMBER(38),
EMPNAME VARCHAR2(9),
EMP_SALES_AMOUNT NUMBER(5),
EMP_SALES_DATE DATE,
CONSTRAINT PK_EMP_03 PRIMARY KEY (EMP_ID) USING INDEX TABLESPACE EMP_TABLESPACE
) NOLOGGING PARALLEL 4 TABLESPACE EMP_TABLESPACE
PARTITION BY RANGE(EMP_SALES_DATE)
INTERVAL (numtodsinterval(1,'day'))
STORE IN (EMP_TABLESPACE)
PARTITION P0 VALUES LESS THAN (to_date('23-AUG-2012','DD-MON-YYYY')) NOLOGGING
Insert Script :
INSERT INTO TBL_EMP_SALES VALUES (1001,'A',50,SYSDATE);
INSERT INTO TBL_EMP_SALES VALUES (1002,'B',100,SYSDATE+1);
INSERT INTO TBL_EMP_SALES VALUES (1003,'C',80,SYSDATE+2);
INSERT INTO TBL_EMP_SALES VALUES (1004,'D',250,SYSDATE+3);
INSERT INTO TBL_EMP_SALES VALUES (1005,'E',50,SYSDATE+4);
INSERT INTO TBL_EMP_SALES VALUES (1006,'F',50,SYSDATE+5);
INSERT INTO TBL_EMP_SALES VALUES (1007,'G',340,SYSDATE+6);
INSERT INTO TBL_EMP_SALES VALUES (1008,'H',120,SYSDATE+7);
COMMIT;
Partitions Created :
select segment_name,partition_name,bytes from user_segments where segment_name = 'TBL_EMP_SALES';
segment_name partition_name bytes
TBL_EMP_SALES P0 8388608
TBL_EMP_SALES SYS_P602 8388608
TBL_EMP_SALES SYS_P603 8388608
TBL_EMP_SALES SYS_P604 8388608
TBL_EMP_SALES SYS_P605 8388608
TBL_EMP_SALES SYS_P606 8388608
TBL_EMP_SALES SYS_P607 8388608
TBL_EMP_SALES SYS_P608 8388608
Thanks,
Varun
Edited by: 900575 on Aug 22, 2012 1:18 AMHi Kev82Fr,
Thanks for the useful post, I have tried your after trigger concept it works well and i have modified the code as below. Is their any other way where i can drop all the partition in the table in one shot ?
--------------------------------------Drop Partition Procedure--------------------------------
create or replace
PROCEDURE USP_PARTITION_DROP_TEST
AS
lv_cmd VARCHAR2(2000);
CURSOR parition_names IS
SELECT partition_name FROM user_segments WHERE segment_name = 'TBL_EMP_SALES';
parition_record parition_names%ROWTYPE;
BEGIN
OPEN parition_names;
LOOP
FETCH parition_names INTO parition_record;
EXIT WHEN parition_names%NOTFOUND;
SELECT 'ALTER TABLE TBL_EMP_SALES DROP PARTITION '||parition_record INTO lv_cmd FROM DUAL;
EXECUTE IMMEDIATE lv_cmd;
END LOOP;
CLOSE parition_names;
END USP_PARTITION_DROP_TEST;
---------------- After Truncate Trigger-----------------------------------
CREATE OR REPLACE TRIGGER TRG_PARTITION_DROP
after truncate on <SCHEMA NAME>.SCHEMA
BEGIN
USP_PARTITION_DROP_TEST();
END;
Thanks,
Varun -
Use securefile for new partitions made by interval partitioning
I am using Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production.
I have a range partitioned table having lobs as basicfile. Due to storage issue and other business constraints , it is determined not to change existing lobs to securefile.
However ,we want new lobs to be in securefile and alter table to have interval partition+.
While researching, I found sql to change lob in range partition to securefile by using
alter table t1 add partition t1_p2 value less than (10000) lob (col3) store as securefile (tablespace tbs_sf1)Please advise me to do similar in case of interval partition.
Many thanks for assistance.>
Can we modify default attribute of lob to store as securefile for partition table.
>
Yes - that is what I meant in my reply. But it seems I may have been wrong since after further testing I was able to find syntax that would appear to work for you. Please test this and post the results.
The line
LOB(CLOB_DATA) store as securefileshould store intervals as securefile. But it accepted syntax to store the predefined partitions as basicfile
PARTITION P0 VALUES LESS THAN
(TO_DATE(' 2008-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
LOB(CLOB_DATA) store as basicfile,I don't have time to test with data until next week. But if this works you could predefine all of your partitions that you want to use basicfile for and then use interval partitions for the ones you want securefile for. That sounded like what you were trying to do.
DROP TABLE INTERVAL_SALES1 CASCADE CONSTRAINTS;
CREATE TABLE INTERVAL_SALES1
PROD_ID NUMBER(6),
CUST_ID NUMBER,
TIME_ID DATE,
CHANNEL_ID CHAR(1 BYTE),
PROMO_ID NUMBER(6),
QUANTITY_SOLD NUMBER(3),
AMOUNT_SOLD NUMBER(10,2),
CLOB_DATA CLOB
LOB(CLOB_DATA) store as securefile
PARTITION BY RANGE (TIME_ID)
INTERVAL( NUMTOYMINTERVAL(1,'MONTH'))
PARTITION P0 VALUES LESS THAN
(TO_DATE(' 2008-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
LOB(CLOB_DATA) store as basicfile,
PARTITION P1 VALUES LESS THAN (TO_DATE(' 2009-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P2 VALUES LESS THAN (TO_DATE(' 2009-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
PARTITION P3 VALUES LESS THAN (TO_DATE(' 2010-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
)Post the results of any testing you do. -
Requirement:
Replace Interval partitioned Table by Range Partitioned Table
DROP TABLE A;
CREATE TABLE A
a NUMBER,
CreationDate DATE
PARTITION BY RANGE (CreationDate)
INTERVAL ( NUMTODSINTERVAL (30, 'DAY') )
(PARTITION P_FIRST
VALUES LESS THAN (TIMESTAMP ' 2001-01-01 00:00:00'));
INSERT INTO A
VALUES (1, SYSDATE);
INSERT INTO A
VALUES (1, SYSDATE - 30);
INSERT INTO A
VALUES (1, SYSDATE - 60);I need to change this Interval Partitioned Table to a Range Partitioned Table. Can I do it using EXCHANGE PARTITION. As if I use the conventional way of creating another Range Partitioned table and then :
DROP TABLE A_Range
CREATE TABLE A_Range
a NUMBER,
CreationDate DATE
PARTITION BY RANGE (CreationDate)
(partition MAX values less than (MAXVALUE));
Insert /*+ append */ into A_Range Select * from A; --This Step takes very very long..Trying to cut it short using Exchange Partition.Problems:
I can't do
ALTER TABLE A_Range
EXCHANGE PARTITION MAX
WITH TABLE A
WITHOUT VALIDATION;
ORA-14095: ALTER TABLE EXCHANGE requires a non-partitioned, non-clustered table
This is because both the tables are partitioned. So it does not allow me.
If I do instead :
create a non partitioned table for exchanging the data through partition.
Create Table A_Temp as Select * from A;
ALTER TABLE A_Range
EXCHANGE PARTITION MAX
WITH TABLE A_TEMP
WITHOUT VALIDATION;
select count(*) from A_Range partition(MAX);
-Problem is that all the data goes into MAX Partition.
Even after creating a lot of partitions by Splitting Partitions, still the data is in MAX Partition only.
So:
-- Is it that we can't Replace an Interval Partitioned Table by Range Partitioned Table using EXCHANGE PARTITION. i.e. We will have to do Insert into..
-- We can do it but I am missing something over here.
-- If all the data is in MAX Partition because of "WITHOUT VALIDATION" , can we make it be redistributed in the right kind of range partitions.You will need to pre-create the partitions in a_range, then exchange them one by one from a to a tmp then then to arange. Using your sample (thanks for proviing the code by the way).
SQL> CREATE TABLE A
2 (
3 a NUMBER,
4 CreationDate DATE
5 )
6 PARTITION BY RANGE (CreationDate)
7 INTERVAL ( NUMTODSINTERVAL (30, 'DAY') )
8 (PARTITION P_FIRST
9 VALUES LESS THAN (TIMESTAMP ' 2001-01-01 00:00:00'));
Table created.
SQL> INSERT INTO A VALUES (1, SYSDATE);
1 row created.
SQL> INSERT INTO A VALUES (1, SYSDATE - 30);
1 row created.
SQL> INSERT INTO A VALUES (1, SYSDATE - 60);
1 row created.
SQL> commit;
Commit complete.You can find the existing partitions form a using:
SQL> select table_name, partition_name, high_value
2 from user_tab_partitions
3 where table_name = 'A';
TABLE_NAME PARTITION_NAME HIGH_VALUE
A P_FIRST TO_DATE(' 2001-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
A SYS_P44 TO_DATE(' 2013-01-28 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
A SYS_P45 TO_DATE(' 2012-12-29 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
A SYS_P46 TO_DATE(' 2012-11-29 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAYou can then create table a_range with the apporopriate partitions. Note that you may need to create additional partitions in a_range because interval partitioning does not create partitions that it has no data for, even if that leaves "holes" in the partitioning scheme. So, based on the above:
SQL> CREATE TABLE A_Range (
2 a NUMBER,
3 CreationDate DATE)
4 PARTITION BY RANGE (CreationDate)
5 (partition Nov_2012 values less than (to_date('30-nov-2012', 'dd-mon-yyyy')),
6 partition Dec_2012 values less than (to_date('31-dec-2012', 'dd-mon-yyyy')),
7 partition Jan_2013 values less than (to_date('31-jan-2013', 'dd-mon-yyyy')),
8 partition MAX values less than (MAXVALUE));
Table created.Now, create a plain table to use in the exchanges:
SQL> CREATE TABLE A_tmp (
2 a NUMBER,
3 CreationDate DATE);
Table created.and exchange all of the partitions:
SQL> ALTER TABLE A
2 EXCHANGE PARTITION sys_p44
3 WITH TABLE A_tmp;
Table altered.
SQL> ALTER TABLE A_Range
2 EXCHANGE PARTITION jan_2013
3 WITH TABLE A_tmp;
Table altered.
SQL> ALTER TABLE A
2 EXCHANGE PARTITION sys_p45
3 WITH TABLE A_tmp;
Table altered.
SQL> ALTER TABLE A_Range
2 EXCHANGE PARTITION dec_2012
3 WITH TABLE A_tmp;
Table altered.
SQL> ALTER TABLE A
2 EXCHANGE PARTITION sys_p46
3 WITH TABLE A_tmp;
Table altered.
SQL> ALTER TABLE A_Range
2 EXCHANGE PARTITION nov_2012
3 WITH TABLE A_tmp;
Table altered.
SQL> select * from a;
no rows selected
SQL> select * from a_range;
A CREATIOND
1 23-NOV-12
1 23-DEC-12
1 22-JAN-13John -
11gr1 interval partition issues
1st problem.
How to delete the last non interval partition?
When I try it says it is the last non interval..
2nd
How to determine which partitions have the interval applied to them?
Where is the metadata for that? I am unable to find it.
3rd
Is it possible to alter a partition to a interval or non-interval partition type?
All help is appreciated.
Thanks,
Steven
Edited by: user12067909 on May 19, 2010 12:34 PMuser12067909 wrote:
Again HIGH_VALUE appears to have no involvement with intervals in 11GR1.This has nothing to do with HIGH_VALUE. Forget agout interval partitioning for a moment. Oracle does not allow partitioned tables that currently have no partitions. Regardless what type of partitioning you are using, table must have at least one partition. Therefore, you can't drop past partition. Now back to interval partitions. This type of partitioning has "named" partitions (like p0 in your case) and "unnamed" partitions dynamically created when you insert data. These "unnamed" partitions are not part of table definition:
SQL> create table t1p
2 ( a number,
3 sdate date
4 )
5 partition by range(sdate)
6 interval (numtodsinterval(1,'day'))
7 (partition p0 values less than
8 (to_date('12-apr-2009','dd-mon-yyyy'))
9 )
10 /
Table created.
SQL> insert into t1p ( a,sdate )
2 values ( 1,to_date('20100101','yyyymmdd'));
1 row created.
SQL> insert into t1p ( a,sdate )
2 values ( 1,to_date('20090101','yyyymmdd'));
1 row created.
SQL> commit
2 /
Commit complete.
SQL>
SQL> select partition_name from user_tab_partitions where table_name = 'T1P'
2 /
PARTITION_NAME
P0
SYS_P46
SQL> set long 10000
SQL> select dbms_metadata.get_ddl('TABLE','T1P') from dual
2 /
DBMS_METADATA.GET_DDL('TABLE','T1P')
CREATE TABLE "SCOTT"."T1P"
( "A" NUMBER,
"SDATE" DATE
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(
BUFFER_POOL DEFAULT)
TABLESPACE "USERS"
PARTITION BY RANGE ("SDATE") INTERVAL (NUMTODSINTERVAL(1,'DAY'))
(PARTITION "P0" VALUES LESS THAN (TO_DATE(' 2009-04-12 00:00:00', 'SYYYY-MM-DD
HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
DBMS_METADATA.GET_DDL('TABLE','T1P')
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS" NOCOMPRESS )
SQL> So in the sense that dynamically created partitions do not count, error message is misleading. There would not be any error if, for example, there would be two "named" partitions:
SQL> create table t1p
2 ( a number,
3 sdate date
4 )
5 partition by range(sdate)
6 interval (numtodsinterval(1,'day'))
7 (partition p0 values less than
8 (to_date('12-apr-2009','dd-mon-yyyy')),
9 partition p1 values less than
10 (to_date('12-may-2009','dd-mon-yyyy'))
11 )
12 /
Table created.
SQL> alter table t1p drop partition p0
2 /
Table altered.
SQL> But now, as soon as we are down to one "named"partition:
SQL> alter table t1p drop partition p1
2 /
alter table t1p drop partition p1
ERROR at line 1:
ORA-14758: Last partition in the range section cannot be dropped
SQL> SY. -
hi,
is it possible to identify a syntax or wildcard for interval partition naming while creating interval partitioned table?
(of course, a job, sched. job or a script can be used to rename partitions, but my questions is is it possible when creating?)
thanks>
is it possible to identify a syntax or wildcard for interval partition naming while creating interval partitioned table?
(of course, a job, sched. job or a script can be used to rename partitions, but my questions is is it possible when creating?)
>
No - that is not possible.
Why do you care what the name is?
You can use the PARTITION FOR syntax to refer to a particular partition in queries.
alter table DEMO_INTERVAL_DATA_LOAD1 drop partition for (TO_DATE('01-APR-2000','DD-MON-YYYY'));
select count(*) from PART_TEST_TBL subpartition for(10,'BLUE');See the 'partition_extension_clause' of the SELECT statement in the SQL Language doc
http://docs.oracle.com/cd/B28359_01/server.111/b28286/sql_elements009.htm#i165979
>
References to Partitioned Tables and Indexes Tables and indexes can be partitioned. When partitioned, these schema objects consist of a number of parts called partitions, all of which have the same logical attributes. For example, all partitions in a table share the same column and constraint definitions, and all partitions in an index share the same index columns.
Partition-extended and subpartition-extended names let you perform some partition-level and subpartition-level operations, such as deleting all rows from a partition or subpartition, on only one partition or subpartition. Without extended names, such operations would require that you specify a predicate (WHERE clause). For range- and list-partitioned tables, trying to phrase a partition-level operation with a predicate can be cumbersome, especially when the range partitioning key uses more than one column. For hash partitions and subpartitions, using a predicate is more difficult still, because these partitions and subpartitions are based on a system-defined hash function.
Partition-extended names let you use partitions as if they were tables. An advantage of this method, which is most useful for range-partitioned tables, is that you can build partition-level access control mechanisms by granting (or revoking) privileges on these views to (or from) other users or roles. To use a partition as a table, create a view by selecting data from a single partition, and then use the view as a table. -
Partitioned nested table error while dropping one partition
All,
I created a partitioned table which is also a nested table as you can see below. I got FK constraint error while attempting to drop a partition, however, I could not find the FK in order to disable it since it's underlying table emp_list_p which is not visiable to applications. How could I drop the partition in this case?
Thanks,
Jianhui
SQL>desc emp_t
Name Null? Type
ENO NUMBER
ENAME VARCHAR2(30)
SAL NUMBER
SQL>desc emp_list_t
emp_list_t TABLE OF EMP_T
Name Null? Type
ENO NUMBER
ENAME VARCHAR2(30)
SAL NUMBER
SQL>l
1 create table dept_p
2 (dno number,
3 dname varchar2(30),
4 emplist emp_list_t )
5 NESTED TABLE emplist store as emp_list_p
6 partition by range (dno)
7 (
8 partition p1 values less than (2),
9 partition p2 values less than (3)
10* )
SQL>/
Table created.
SQL>insert into dept_p (select * from dept);
2 rows created.
SQL>select * from dept_p;
DNO DNAME
EMPLIST(ENO, ENAME, SAL)
1 HR
EMP_LIST_T(EMP_T(1, 'scott', 1000), EMP_T(2, 'brain', 2000))
2 SALES
EMP_LIST_T(EMP_T(3, 'frank', 800))
2 rows selected.
SQL>alter table dept_p drop partition p1;
alter table dept_p drop partition p1
ERROR at line 1:
ORA-02266: unique/primary keys in table referenced by enabled foreign keys
SQL>l
1 select constraint_name, constraint_type, table_name
2 from user_constraints
3 where r_constraint_name=(select constraint_name
4* from user_constraints where table_name='DEPT_P' and constraint_type in ('P','U'))
SQL>/
no rows selectedSQL> create type emp_t as object(
2 ENO NUMBER,
3 ENAME VARCHAR2(30),
4 SAL NUMBER)
5 /
Type created.
SQL> create type emp_list_t as table of emp_t;
2 /
Type created.
SQL> desc emp_list_t
emp_list_t TABLE OF EMP_T
Name Null? Type
ENO NUMBER
ENAME VARCHAR2(30)
SAL NUMBER
SQL> create table dept_p
2 (dno number,
3 dname varchar2(30),
4 emplist emp_list_t )
5 NESTED TABLE emplist store as emp_list_p
6 partition by range (dno)
7 (
8 partition p1 values less than (2),
9 partition p2 values less than (3)
10 )
11 /
Table created.
SQL> insert into dept_p values(1, 'HR',
2 EMP_LIST_T(EMP_T(1, 'scott', 1000), EMP_T(2, 'brain', 2000)));
1 row created.
SQL>
SQL> insert into dept_p values(2, 'SALES',EMP_LIST_T(EMP_T(3, 'frank', 800)));
1 row created.
SQL> select * from dept_p;
DNO DNAME
EMPLIST(ENO, ENAME, SAL)
1 HR
EMP_LIST_T(EMP_T(1, 'scott', 1000), EMP_T(2, 'brain', 2000))
2 SALES
EMP_LIST_T(EMP_T(3, 'frank', 800))
SQL> alter table dept_p drop partition p1;
alter table dept_p drop partition p1
ERROR at line 1:
ORA-02266: unique/primary keys in table referenced by enabled foreign keys
SQL> select constraint_name,table_name,constraint_type from user_constraints
2 where table_name = 'DEPT_P';
CONSTRAINT_NAME TABLE_NAME C
SYS_C008224 DEPT_P U
SQL> select index_name from user_constraints
2 where table_name = 'DEPT_P';
INDEX_NAME
SYS_C008224
SQL> select index_name,column_name from user_ind_columns
2 where index_name = 'SYS_C008224';
INDEX_NAME COLUMN_NAME
SYS_C008224 EMPLIST
SQL>
SQL> disconnect
Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - Production
With the Partitioning, OLAP and Data Mining options
If you look closely, there is a unique index on dept_p. Oracle does not advertise it.
One of the options is that you may have to delete the rows in the partition first,
then drop the partition. -
How to drop a partitioned column in a table
Hi All,
I am trying to drop a column which is partitioned into 4 values.
When I use the command
ALTER TABLE TNAME DROP COLUMN CNAME;
I am getting an error message stating that cannot drop a parttioned column.
ALTER TABLE fn_dev_excpt DROP COLUMN THEATER_ID
ERROR at line 1:
ORA-12984: cannot drop partitioning column
Appreciate your help on this,
Thanks,
Madhu K.Hi,
Can you please drop the partition itself using the below command.Dropping of column which is partitioned is not alllowed.
SELECT table_name, partition_name
FROM user_tab_partitions;
ALTER TABLE range_list DROP PARTITION s2k ;
where table_name=range_list ,
partition_name=s2k
Best regards,
Rafi.
http://rafioracledba.blogspot.com/
Edited by: Rafi (Oracle DBA) on Mar 25, 2010 12:58 AM
Maybe you are looking for
-
Can't open downloads to desktop (Error code - 10660)
Hi Everyone, I'm having a problem opening documents that are downloaded to my desktop. I recieve the following error, "The operation could not be completed. An unexpected error occurred (Error code - 10660)." I can go into the required program (i.e.
-
Database Development with JDeveloper tutorial
When I run the EMP_FETCHER body I do not get a Run PL/SQL dialog. Has anyone else had this problem? I using JDeveloper 10.1.3.0.4, Oracle database 10g Express Edition and Windows XP PRO. Thanks
-
Make command not available error
I want to create an action that will apply a set of color adjustment layers to an existing selection in a group. IE. I want to create a group with a selection mask that contains several color type adjustment layers. THis is what I did: Make a selecti
-
The use of functions - a function with other selects (eg. calculate availability of a part) - is slowing down our system when we do a select over our product file. Is there some kind of rule when functions should be used or when we should try to crea
-
Order forms and shopping carts
I'm fairly new to web design, having set up 3 or 4 basic sites. A friend asked me to help him set up a website for his small candy business. It all went fine until I got to the order form. The only thing I could think of was set up a form in a layout