Truncating sub partitions
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.
Similar Messages
-
Add sub partition on another column in oracle
I have a table which has two partitions (by range): first_half and second_half based on a column "INSERT_DAY".
I need to add subpartitions "SUCCESS" and "NONSUCCESS" based on the values of another column "STATUS" (subpartition by list) i.e. I need to transform my range partition to composite (range-list) partition.
I do not wish to drop existing tables or partitions. What is the ALTER query for this?
PS: The database is Oracle 9iOk, my bad. The project is about charging GPRS customers for data usage.
Here is the real DDL:
CREATE TABLE CDR_EVENT_RCD_FILE_MOB_AGG
( "MOBILE_NO" VARCHAR2(16 BYTE),
"DATA_VOLUME" NUMBER(*,0),
"CHARGE" NUMBER(*,0),
"RECORD_COUNT" NUMBER(*,0),
"COUNTER" NUMBER(*,0) DEFAULT 0,
"INSERT_DAY" NUMBER(*,0),
"MAX_FILE_SEQ_NO" NUMBER(*,0),
"MIN_FILE_SEQ_NO" NUMBER(*,0),
"REQUEST_ID" VARCHAR2(21 BYTE),
"TRANSACTION_ID" VARCHAR2(21 BYTE),
"RESPONSE_TIME" TIMESTAMP (6),
"RETURN_CODE" CHAR(2 BYTE),
"FAILURE_REASON" VARCHAR2(1024 BYTE),
"CHARGED_AMOUNT" NUMBER(*,2)
PARTITION BY RANGE ("INSERT_DAY")
(PARTITION "FIRST_HALF" VALUES LESS THAN (16) ,
PARTITION "SECOND_HALF" VALUES LESS THAN (MAXVALUE) ) ;
CREATE INDEX "CDRDEVTBS"."MAX_FILE_SEQ_NO_INDEX" ON "CDRDEVTBS"."CDR_EVENT_RCD_FILE_MOB_AGG" ("MAX_FILE_SEQ_NO") ;
CREATE INDEX "CDRDEVTBS"."MOBILE_NO_INDEX" ON "CDRDEVTBS"."CDR_EVENT_RCD_FILE_MOB_AGG" ("MOBILE_NO") ;
As you can see, it is partitioned by range on "Insert_day".
The requirement is to delete all the records having counter=3 (which means successful charging) for the records which are older than 15 days.
So I thought, why not create sub partitions with counter so that final DDL would be something like the following. I would then avoid writing a DELETE query, which would take a lot of time to execute.
CREATE TABLE CDR_EVENT_RCD_FILE_MOB_AGG (
insert_day INT,
counter INT,
--other columns
PARTITION BY RANGE (insert_day)
SUBPARTITION BY LIST(counter)
SUBPARTITION TEMPLATE
SUBPARTITION SUCCESS VALUES(3),
SUBPARTITION NONSUCCESS VALUES(DEFAULT)
PARTITION first_half VALUES LESS THAN (16),
PARTITION second_half VALUES LESS THAN (maxvalue)
So that I could execute queries:
alter table CDR_EVENT_RCD_FILE_MOB_AGG truncate subpartition first_half_success; --execute on last day of every month
alter table CDR_EVENT_RCD_FILE_MOB_AGG truncate subpartition second_half_success; -- execute on 16th day of every month
to remove unnecessary records.
I would like to create subpartitions without dropping the existing table. -
Oracle v8.1.6.3
The table has 36 major partitions with 32 subs in each part. When we attempt to analyze a specific partition (P2003_05)in a table with 32 sub-partitions, we receive a ORA-3113 error. We know that this is a bogus error because we can analyze all the other partitions and sub-partitions without incident. This is the second time we have had a partition that will need to be exported, truncated and imported before it can be analyzed. I have absolutely no idea what causes this. Any ideas?This forum is for posting feedback about the OTN site.
The best place for your question is probably a Database forum, perhaps the General Database Discussions forum. -
Can sub partitions be unbalanced?
I have a fact table that is partitioned by day (YYYYMMD) and by data source (a 4-character code). The table receives about 200 million records daily - 150 comes from one data source and the rest (about 50 mn) comes from 8 data sources (2 mn avg from 4 sources, 8mn avg from 4 sources). The reason this is being thought is that data from the 8 data sources are being loaded in parallel and if any fail, the entire sub partition can be truncated and data reloaded.
Is this the right partitioning strategy: composite partition - range (by day) and list subpartition (by data source), given that the sub-partitions will be very unbalanced?
Thanks for your thoughts!
KitUnbalanced has no meaning within the context of RANGE-LIST composite partitioning.
The records go where the partition template directs them.
If you want all of your subpartitions to contain a roughly equal number of records use RANGE-HASH. -
Problem in truncate/drop partitions in a table having nested table columns.
Hi,
I have a table that has 2 columns of type nested table. Now in the purge process, when I try to truncate or drop a partition from this table, I get error that I can't do this (because table has nested tables). Can anybody help me telling how I will be able to truncate/drop partition from this table? IF I change column types from nested table to varray type, will it help?
Also, is there any short method of moving existing data from a nested table column to a varray column (having same fields as nested table)?
Thanks in advance.>
I have a table that has 2 columns of type nested table. Now in the purge process, when I try to truncate or drop a partition from this table, I get error that I can't do this (because table has nested tables). Can anybody help me telling how I will be able to truncate/drop partition from this table?
>
Unfortunately you can't do those operations when a table has a nested table column. No truncate, no drop, no exchange partition at the partition level.
A nested table column is stored as a separate table and acts like a 'child' table with foreign keys to the 'parent' table. It is these 'foreign keys' that prevent the truncation (just like normal foreign keys prevent truncating partions and must be disabled first) but there is no mechanism to 'disable' them.
Just one excellent example (there are many others) of why you should NOT use object columns at all.
>
IF I change column types from nested table to varray type, will it help?
>
Yes but I STRONGLY suggest you take this opportunity to change your data model to a standard relational one and put the 'child' (nested table) data into its own table with a foreign key to the parent. You can create a view on the two tables that can make data appear as if you have a nested table type if you want.
Assuming that you are going to ignore the above advice just create a new VARRAY type and a table with that type as a column. Remember VARRAYs are defined with a maximum size. So the number of nested table records needs to be within the capacity of the VARRAY type for the data to fit.
>
Also, is there any short method of moving existing data from a nested table column to a varray column (having same fields as nested table)?
>
Sure - just CAST the nested table to the VARRAY type. Here is code for a VARRAY type and a new table that shows how to do it.
-- new array type
CREATE OR REPLACE TYPE ARRAY_T AS VARRAY(10) OF VARCHAR2(64)
-- new table using new array type - NOTE there is no nested table storage clause - arrays stored inline
CREATE TABLE partitioned_table_array
( ID_ INT,
arra_col ARRAY_T )
PARTITION BY RANGE (ID_)
( PARTITION p1 VALUES LESS THAN (40)
, PARTITION p2 VALUES LESS THAN(80)
, PARTITION p3 VALUES LESS THAN(100)
-- insert the data from the original table converting the nested table data to the varray type
INSERT INTO PARTITIONED_TABLE_ARRAY
SELECT ID_, CAST(NESTED_COL AS ARRAY_T) FROM PARTITIONED_TABLENaturally since there is no more nested table storage you can truncate or drop partitions in the above table
alter table partitioned_table_array truncate partition p1
alter table partitioned_table_array drop partition p1 -
Sub Partitioning does not have considerable impact Explain Plan
Hi Guys,
I have a table that is list - list sub partitioned on Oracle 11g - 11.2.0.3.
The first partition is on the CIRCLE_ID column and the second sub partition is on the LOAD_DTTM.
Now i have tried 2 queries on the database
1 - select MOBILENUMBER, CLOSING_BAL from GSM_PRR_SUM a1
where A1.CIRCLE_ID ='AK'
AND a1.LOAD_DTTM BETWEEN '28-MAR-2012' AND '03-APR-2012';
2 - select MOBILENUMBER, CLOSING_BAL from GSM_PRR_SUM a1
where A1.CIRCLE_ID ='AK'
AND to_char(a1.LOAD_DTTM) like '%MAR%'
Ideally the 2nd query should take a much higher time than the first query.
But the explain plan shows a difference of less than 1%.
Can you pls provide some insights as why Oracle is not understanding that subpartitioning will be faster?
Thanks,
ManishHi Dom
Thanks for your reply.
Is the first query using partition pruning? - Yes
Have you gathered stats, etc, etc? - No. All our queries always need to access the entire table and not a particular subset and the where criteria always uses partition and sub partition columns. so we dont see the need to collect stats. Can you pls advise what stats need to be collected and what will be the advantage of those?
Below are the output of the Explain Plan and Trace Output -
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> show parameter optimizer;
NAME TYPE VALUE
optimizer_capture_sql_plan_baselines boolean FALSE
optimizer_dynamic_sampling integer 2
optimizer_features_enable string 11.2.0.3
optimizer_index_caching integer 0
optimizer_index_cost_adj integer 100
optimizer_mode string ALL_ROWS
optimizer_secure_view_merging boolean TRUE
optimizer_use_invisible_indexes boolean FALSE
optimizer_use_pending_statistics boolean FALSE
optimizer_use_sql_plan_baselines boolean TRUE
SQL> show parameter db_file_multi;
NAME TYPE VALUE
db_file_multiblock_read_count integer 128
SQL> show parameter cursor_sharing
NAME TYPE VALUE
cursor_sharing string EXACT
SQL> column sname format a20
SQL> column pname foramt 20
SP2-0158: unknown COLUMN option "foramt"
SQL> column pname format a20
SQL> column pval2 format a20
SQL> select
2 sname
3 , pname
4 , pval1
5 ,pval2
6 from sys.aux_stats$;
from sys.aux_stats$
ERROR at line 6:
ORA-00942: table or view does not exist
SQL> explain plan for
select MOBILENUMBER, CLOSING_BAL from GSM_PRR_SUM_NEW a1
where A1.CIRCLE_ID ='KA'
AND a1.LOAD_DTTM BETWEEN '28-MAR-2012' AND '03-APR-2012'
SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);
PLAN_TABLE_OUTPUT
Plan hash value: 3032220315
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)
| Time | Pstart| Pstop |
PLAN_TABLE_OUTPUT
| 0 | SELECT STATEMENT | | 41M| 1643M| 548M(100)
|999:59:59 | | |
| 1 | PARTITION LIST SINGLE | | 41M| 1643M| 548M(100)
|999:59:59 | KEY | KEY |
| 2 | PARTITION LIST ITERATOR| | 41M| 1643M| 548M(100)
|999:59:59 | KEY | KEY |
| 3 | TABLE ACCESS FULL | GSM_PRR_SUM_NEW | 41M| 1643M| 548M(100)
|999:59:59 | KEY | KEY |
PLAN_TABLE_OUTPUT
Note
- dynamic sampling used for this statement (level=2)
14 rows selected.
SQL> explain plan for
select MOBILENUMBER, CLOSING_BAL from GSM_PRR_SUM_NEW a1
where A1.CIRCLE_ID ='KA'
AND to_char(a1.LOAD_DTTM) like '%MAR%';
2 3 4
Explained.
SQL> SQL> SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);
PLAN_TABLE_OUTPUT
Plan hash value: 189546713
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| T
ime | Pstart| Pstop |
PLAN_TABLE_OUTPUT
| 0 | SELECT STATEMENT | | 62M| 2521M| 5435M(100)|99
9:59:59 | | |
| 1 | PARTITION LIST SINGLE| | 62M| 2521M| 5435M(100)|99
9:59:59 | KEY | KEY |
| 2 | PARTITION LIST ALL | | 62M| 2521M| 5435M(100)|99
9:59:59 | 1 | 305 |
|* 3 | TABLE ACCESS FULL | GSM_PRR_SUM_NEW | 62M| 2521M| 5435M(100)|99
9:59:59 | KEY | KEY |
PLAN_TABLE_OUTPUT
Predicate Information (identified by operation id):
3 - filter(TO_CHAR(INTERNAL_FUNCTION("A1"."LOAD_DTTM")) LIKE '%MAR%')
Note
PLAN_TABLE_OUTPUT
- dynamic sampling used for this statement (level=2)
19 rows selected.
SQL>
SQL> SET AUTOTRACE TRACEONLY ARRAYSIZE 100
SQL> select MOBILENUMBER, CLOSING_BAL from GSM_PRR_SUM_NEW a1
where A1.CIRCLE_ID ='KA'
AND a1.LOAD_DTTM BETWEEN '28-MAR-2012' AND '03-APR-2012' 2 3 ;
49637012 rows selected.
Execution Plan
Plan hash value: 3032220315
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)
| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 41M| 1643M| 546M(100)
|999:59:59 | | |
| 1 | PARTITION LIST SINGLE | | 41M| 1643M| 546M(100)
|999:59:59 | KEY | KEY |
| 2 | PARTITION LIST ITERATOR| | 41M| 1643M| 546M(100)
|999:59:59 | KEY | KEY |
| 3 | TABLE ACCESS FULL | GSM_PRR_SUM_NEW | 41M| 1643M| 546M(100)
|999:59:59 | KEY | KEY |
Note
- dynamic sampling used for this statement (level=2)
Statistics
0 recursive calls
7 db block gets
530220 consistent gets
33636 physical reads
0 redo size
644311477 bytes sent via SQL*Net to client
5460594 bytes received via SQL*Net from client
496372 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
49637012 rows processed
SQL> SET AUTOTRACE TRACEONLY ARRAYSIZE 100
SQL> select MOBILENUMBER, CLOSING_BAL from GSM_PRR_SUM_NEW a1
where A1.CIRCLE_ID ='KA'
AND to_char(a1.LOAD_DTTM) like '%MAR%' 2 3
4 ;
219166976 rows selected.
Execution Plan
Plan hash value: 189546713
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| T
ime | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 228M| 9155M| 3552M(100)|99
9:59:59 | | |
| 1 | PARTITION LIST SINGLE| | 228M| 9155M| 3552M(100)|99
9:59:59 | KEY | KEY |
| 2 | PARTITION LIST ALL | | 228M| 9155M| 3552M(100)|99
9:59:59 | 1 | 274 |
|* 3 | TABLE ACCESS FULL | GSM_PRR_SUM_NEW | 228M| 9155M| 3552M(100)|99
9:59:59 | KEY | KEY |
Predicate Information (identified by operation id):
3 - filter(TO_CHAR(INTERNAL_FUNCTION("A1"."LOAD_DTTM")) LIKE '%MAR%')
Note
- dynamic sampling used for this statement (level=2)
Statistics
38 recursive calls
107 db block gets
2667792 consistent gets
561765 physical reads
0 redo size
2841422984 bytes sent via SQL*Net to client
24108883 bytes received via SQL*Net from client
2191671 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
219166976 rows processed
SQL>
Thanks,
Manish -
Any overhead with sub partitioning within a time based column?
We have a table that's partitioned based on a weekly partition and it has records of Type A and records of Type B and there are processes that are only interested in records of Type B.
Right now the table is partitioned as interval on the timestamp column as a weekly partitioning but I'm considering introducing sub partitioning into the mix based on these record Types.
Is that feasible?>
We have a table that's partitioned based on a weekly partition and it has records of Type A and records of Type B and there are processes that are only interested in records of Type B.
>
Whether to partition on the 'type' column depends on the data skew and how the type data is accessed.
If the access and skew is such that an index would be used then just use an index - no need to partition. For example if only 5% of the data is Type B then you could probably use an index effectively for accessing only Type B data.
For Type A data (95%) a full table scan will be used and Oracle will skip/ignore the 5% of the data this Type B so no partitioning is needed.
Subpartitioning would be useful if an index won't help filter the data and you want Oracle to filter it automatically.
You will need to either redefine the table (using DBMS_REDEFINITION) or recreate the table to if you want to add subpartitioning. -
Truncating/droping partitions
i have to drop around 20 partitions for a particular table .
the scripts are ready for droping and i have taken a logical export of 20 partitions.
one thing i have realised is that the table have lot of constarints .
my first question
whether constraints need to be dropped/diabled before you can truncate/drop a partition on a partitioned table.
i have a testing env also
i ftpd the the logical export file and the truncate scripts to the UAT.
the UAT env is just a clone of PROD .. so iam trying to import the 20 partitions into the UAT same schema and the same table structure (pls note UAT has got just 5 partitions only)
while importing i got a new error it says the not null constarint is violated and the unique constarint is violated. i thought there might be a flaw withthe source Db .so i ISSUED SOME QuERIES TO FIND IF THERE ARE null values there and if there are any duplicate records.. the result was no duplicates or null records found.
so the source is ok
i turned my eye towards UAT env
i tried to import the records into the same schema and the same table in UAT.so while doing the import the following was the error
import: Release 9.2.0.5.0 - Production on Mon Apr 16 11:46:51 2007
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Username: / as sysdba
Connected to: Oracle9i Enterprise Edition Release 9.2.0.5.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.5.0 - Production
Export file created by EXPORT:V09.02.00 via direct path
Warning: the objects were exported by ORACLE, not by you
import done in US7ASCII character set and UTF8 NCHAR character set
. importing ORACLE's objects into SYS
. importing NEVADMIN's objects into NEVADMIN
. . importing partition "BO_NEV_RETENTION":"BO_NEV_RETENTION_M1" 0 rows imported
. . importing partition "BO_NEV_RETENTION":"BO_NEV_RETENTION_M2"
IMP-00019: row rejected due to ORACLE error 1
IMP-00003: ORACLE error 1 encountered
ORA-00001: unique constraint (NEVADMIN.BO_NEV_RETENTION_PK) violated
Column : 177943769
Column : 30-SEP-2002:00:00:00
Column : 30-SEP-2002:00:00:00
Column : 1214339
Column : 10676375
Column : 28
Column : 140413
Column : 140427
Column : 4533749
Column : 1176777
Column : 8
Column : 61
Column : 3
Column : 1631232
Column : 1
Column : 12181566
Column : 211
Column : 0
Column : 399000
Column : 146500
IMP-00019: row rejected due to ORACLE error 1400
IMP-00003: ORACLE error 1400 encountered
ORA-01400: cannot insert NULL into ("NEVADMIN"."BO_NEV_RETENTION"."PARENT_MTG_LOAN_KEY")
Column :
Column : ?...
Column : 30-SEP-2002:00:00:00
Column : -2.92710000000000E-116
Column : 1214526
Column : 10678618
Column : 26
Column : 140197
Column : 140210
Column : 4409141
Column : 1176777
Column : -1
Column : 61
Column : 1
Column : -1
Column : 1
Column : 12127061
Column : 31
Column : 0
Column : 389825124.7
IMP-00009: abnormal end of export file
Import terminated successfully with warnings
my second question would be
is there any flaw with my import.
this wat i did while i treied to import into the schema
$imp userid=/ as sysdba commit=y file=/ / /.dmp log=test.log ignore=y full=y buffer=100000
kindly let me know wat could be the problem!If truncating multiple partitions existed, it could also support updating global indexes clause (supported currently for truncating one partition) - which behaves differently from complete index rebuild and probably suites better for some cases. Just faced with that "want-this-feature" also ).
Combining maintenance operations for multiple partitions in one "multipartition" operation would be useful in some cases. For example partitions merge in one step would generate many times less redo than equivalent partition cycle. Had to implement that "multipartition" merge using insert into another table, truncate original partitions, merge empty partitions, exchange merged partition with this table, which works faster, but is not so reliable as potential "multipartition" operation... -
How to truncate a partition in owb
I wonder how can i achieve truncating a partition before loading into this target table. I found this pre-mapping prcess where we have this option of truncating a table, but how can i just truncate a partition within a table in a mapping? please advice.
~PrabhaAs per Detlef's suggestion, here's the basics that you can embedd in a function/procedure. Accepts 3 parameters in_table_name, in_subpartition_name and in_partition_name. You can also enhance ALTER statements to REUSE/DROP STORAGE if required.
v_sql VARCHAR2(250) DEFAULT NULL;
BEGIN
IF in_subpartition_name IS NOT NULL THEN
v_sql := 'ALTER TABLE '||in_table_name||' TRUNCATE SUBPARTITION '||in_subpartition_name;
ELSIF in_partition_name IS NOT NULL THEN
v_sql := 'ALTER TABLE '||in_table_name||' TRUNCATE PARTITION '||in_partition_name;
ELSE
RAISE no_data_found;
END IF;
EXECUTE IMMEDIATE v_sql; -
Can we addnew partition and sub partition in the existing table in one shor
can we addnew partition and sub partition in the existing table in one short
nav wrote:
can we addnew partition and sub partition in the existing table in one shortYes,
You can and below is the example for Range-List partition
ALTER TABLE <table_name>
ADD PARTITION <partition_name> VALUES LESS THAN (<value>
STORAGE (INITIAL 20K NEXT 20K) TABLESPACE <TS name> NOLOGGING
SUBPARTITION Clause
SUBPARTITION Clause
SUBPARTITION Clause
SUBPARTITION Clause
); -
Create local spatial index on range sub-partitions?
Is is possible to create a local spatial index on a table with range sub-partitions? We're trying to do this on a table that contains lots of x,y,z point data.
Trying to do so gives me the error: ORA-29846: cannot create a local domain index on a composite partitioned tableAccording to the spatial documentation:The following restrictions apply to spatial index partitioning:
- The partition key for spatial tables must be a scalar value, and must not be a spatial column.
- Only range partitioning is supported on the underlying table. All other kinds of partitioning are not currently
supported for partitioned spatial indexes.So there is nothing saying it can or can't be done. The examples I've seen in the documentation tend to partition based on a single value and don't use subpartitioning.
Example of what we're trying to do:SQL> SELECT * FROM V$VERSION;
BANNER
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
PL/SQL Release 11.1.0.7.0 - Production
CORE 11.1.0.7.0 Production
TNS for 64-bit Windows: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - Production
SQL>
SQL> --- Create a table, partioned by X and subpartitioned by Y
SQL> CREATE TABLE sub_partition_test
2 (
3 x NUMBER,
4 y NUMBER,
5 z NUMBER,
6 geometry MDSYS.SDO_GEOMETRY
7 )
8 PARTITION BY RANGE (x)
9 SUBPARTITION BY RANGE (y)
10 (
11 PARTITION p_x100 VALUES LESS THAN (100)
12 (
13 SUBPARTITION sp_x100_y100 VALUES LESS THAN (100),
14 SUBPARTITION sp_x100_y200 VALUES LESS THAN (200),
15 SUBPARTITION sp_x100_yMAXVALUE VALUES LESS THAN (MAXVALUE)
16 ),
17 PARTITION p_x200 VALUES LESS THAN (200)
18 (
19 SUBPARTITION sp_x200_y100 VALUES LESS THAN (100),
20 SUBPARTITION sp_x200_y200 VALUES LESS THAN (200),
21 SUBPARTITION sp_x200_yMAXVALUE VALUES LESS THAN (MAXVALUE)
22 ),
23 PARTITION p_xMAXVALUE VALUES LESS THAN (MAXVALUE)
24 (
25 SUBPARTITION sp_xMAXVALUE_y100 VALUES LESS THAN (100),
26 SUBPARTITION sp_xMAXVALUE_y200 VALUES LESS THAN (200),
27 SUBPARTITION sp_xMAXVALUE_yMAXVALUE VALUES LESS THAN (MAXVALUE)
28 )
29 );
Table created.
SQL>
SQL> -- Insert some sample data
SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
2 VALUES (1, 1, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(1, 1, 50), NULL, NULL));
1 row created.
SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
2 VALUES (50, 150, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(50, 150, 50), NULL, NULL));
1 row created.
SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
2 VALUES (150, 150, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(150, 150, 50), NULL, NULL));
1 row created.
SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
2 VALUES (150, 250, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(150, 250, 50), NULL, NULL));
1 row created.
SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
2 VALUES (150, 300, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(150, 300, 50), NULL, NULL));
1 row created.
SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
2 VALUES (220, 210, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(220, 210, 50), NULL, NULL));
1 row created.
SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
2 VALUES (220, 150, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(220, 150, 50), NULL, NULL));
1 row created.
SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
2 VALUES (220, 250, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(220, 250, 50), NULL, NULL));
1 row created.
SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
2 VALUES (220, 300, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(220, 300, 50), NULL, NULL));
1 row created.
SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
2 VALUES (320, 250, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(320, 250, 50), NULL, NULL));
1 row created.
SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
2 VALUES (320, 160, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(320, 160, 50), NULL, NULL));
1 row created.
SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
2 VALUES (320, 290, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(320, 290, 50), NULL, NULL));
1 row created.
SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
2 VALUES (320, 320, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(320, 320, 50), NULL, NULL));
1 row created.
SQL>
SQL> -- Create some metadata
SQL> DELETE FROM user_sdo_geom_metadata WHERE TABLE_NAME = 'SUB_PARTITION_TEST';
1 row deleted.
SQL> INSERT INTO user_sdo_geom_metadata VALUES ('SUB_PARTITION_TEST','GEOMETRY',
2 SDO_DIM_ARRAY(
3 SDO_DIM_ELEMENT('X', 0, 1000, 0.005),
4 SDO_DIM_ELEMENT('Y', 0, 1000, 0.005)
5 ), 262152);
1 row created.
SQL>
SQL> -- Create an Unusable Local Spatial Index
SQL> CREATE INDEX sub_partition_test_spidx ON sub_partition_test (geometry)
2 INDEXTYPE IS MDSYS.SPATIAL_INDEX
3 LOCAL
4 UNUSABLE;
CREATE INDEX sub_partition_test_spidx ON sub_partition_test (geometry)
ERROR at line 1:
ORA-29846: cannot create a local domain index on a composite partitioned tableThanks,
JohnOk, thanks. That's what we're planning on doing now.
SQL> CREATE TABLE partition_test
2 (
3 x NUMBER,
4 y NUMBER,
5 z NUMBER,
6 geometry MDSYS.SDO_GEOMETRY
7 )
8 PARTITION BY RANGE (x, y)
9 (
10 PARTITION p_x100y100 VALUES LESS THAN (100, 100),
11 PARTITION p_x100y200 VALUES LESS THAN (100, 200),
12 PARTITION p_x100yMAX VALUES LESS THAN (100, MAXVALUE),
13 PARTITION p_x200y100 VALUES LESS THAN (200, 100),
14 PARTITION p_x200y200 VALUES LESS THAN (200, 200),
15 PARTITION p_x200yMAX VALUES LESS THAN (200, MAXVALUE),
16 PARTITION p_x300y100 VALUES LESS THAN (300, 100),
17 PARTITION p_x300y200 VALUES LESS THAN (300, 200),
18 PARTITION p_x300yMAX VALUES LESS THAN (MAXVALUE, MAXVALUE)
19 );
Table created.
SQL>
SQL> INSERT INTO user_sdo_geom_metadata VALUES ('PARTITION_TEST','GEOMETRY',
2 SDO_DIM_ARRAY(
3 SDO_DIM_ELEMENT('X', 0, 1000, 0.005),
4 SDO_DIM_ELEMENT('Y', 0, 1000, 0.005)
5 ), 262152);
1 row created.
SQL> CREATE INDEX partition_test_spidx ON partition_test (geometry)
2 INDEXTYPE IS MDSYS.SPATIAL_INDEX
3 LOCAL
4 UNUSABLE;
Index created. -
Truncating first partition created for table partitioned by INTERVAL
Hi,
I have a table created with interval partitions.
When I truncate the partitions, I am unable to truncate the very first partition created on the table. How can I do this?
Thanks.>
When I truncate the partitions, I am unable to truncate the very first partition created on the table
>
I'm going to assume you mean DROP and not TRUNCATE and are getting thel following error when you try to DROP the very first partition
>
ORA-14758: Last partition in the range section cannot be dropped
>
Interval partitioned tables have one or more RANGE partitions and zero or more INTERVAL partitions. The boundary between the LAST range partition and the FIRST interval partition is known as the transition point.
As the error message states you cannot drop the sole remaining RANGE partition that is below the transition point.
You have to move the transition point by merging the last remaining RANGE partition and the first INTERVAL partition. Since dropping a partiton means you no longer want the data you would normally truncate the range partition prior to the merge to minimize the amount of undo and redo that will be generated by the merge.
See this article for an example of how to 'move' the transition point to effectively drop the last remaining RANGE partition.
http://prutser.wordpress.com/2010/01/11/dropping-interval-partitions/ -
Truncating multiple partitions
I am creating a store proc that will truncate selected partitions of a partitioned table. Is there any easy way to do it than the conventional way of looping through cursor and executing multiple alter commands.
alter table <table name> truncate partition p1
alter table <table name> truncate partition p2
alter table <table name> truncate partition p3
and so on..
I am using 10g.If truncating multiple partitions existed, it could also support updating global indexes clause (supported currently for truncating one partition) - which behaves differently from complete index rebuild and probably suites better for some cases. Just faced with that "want-this-feature" also ).
Combining maintenance operations for multiple partitions in one "multipartition" operation would be useful in some cases. For example partitions merge in one step would generate many times less redo than equivalent partition cycle. Had to implement that "multipartition" merge using insert into another table, truncate original partitions, merge empty partitions, exchange merged partition with this table, which works faster, but is not so reliable as potential "multipartition" operation... -
How will write SQL query to fetch data from each Sub-partition..
Hi All,
Anyone does have any idea about How to write SQL query to fetch data from Sub-partition.
Actually i have one table having composite paritition(Range+list)
Now if i want to fetch data from main partition(Range) the query will be
SELECT * FROM emp PARTITION(q1_2005);
Now i want to fetch data at sub-partition level(List) .But i am not able to get any SQL query for that.
Pls help me to sort out.
Thanks in Advance.
AnwarSELECT * FROM emp SUBPARTITION(sp1);
-
How to move partitions/sub-partitions into a different tablespace?
Hi Uisng oracle 1..20.3 and have a range-hash partitioned table using interval partitioning - code below.
Works fine just one problem.
we wish to move the system geneerated partitions to different tablespaces later and also rename th epartitions.
When try assign partition to a different tablespace get the folloiwng message
alter table por_rt move partition SYS_P2283 tablespace bi_dw_data
get message ora-14257 - cannot move partition other than range,list, system or hash partition.
How can we avoid this.
We we need to move all the subpartitions first?
Tried this
alter table move subpartition SYS_SUBP2269 tablespace bi_dw_data;
but get message ora-01735 message invalid statement
-- Create table
create table POR_RT
plant_issue_id NUMBER not null,
pf_run_num NUMBER,
partitioning_date DATE
partition by range (PARTITIONING_DATE)
subpartition by hash (PLANT_ISSUE_ID)
partition PART_200912 values less than (TO_DATE(' 2010-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
tablespace BI_SUPPORT_DATA
pctfree 10
initrans 1
maxtrans 255
subpartition SYS_SUBP2261 tablespace BI_SUPPORT_DATA,
subpartition SYS_SUBP2262 tablespace BI_SUPPORT_DATA,
subpartition SYS_SUBP2263 tablespace BI_SUPPORT_DATA,
subpartition SYS_SUBP2264 tablespace BI_SUPPORT_DATA
partition PART_201001 values less than (TO_DATE(' 2010-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
tablespace BI_SUPPORT_DATA
pctfree 10
initrans 1
maxtrans 255
subpartition SYS_SUBP2265 tablespace BI_SUPPORT_DATA,
subpartition SYS_SUBP2266 tablespace BI_SUPPORT_DATA,
subpartition SYS_SUBP2267 tablespace BI_SUPPORT_DATA,
subpartition SYS_SUBP2268 tablespace BI_SUPPORT_DATA
partition SYS_P2273 values less than (TO_DATE(' 2010-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
tablespace BI_SUPPORT_DATA
pctfree 10
initrans 1
maxtrans 255
subpartition SYS_SUBP2269 tablespace BI_SUPPORT_DATA,
subpartition SYS_SUBP2270 tablespace BI_SUPPORT_DATA,
subpartition SYS_SUBP2271 tablespace BI_SUPPORT_DATA,
subpartition SYS_SUBP2272 tablespace BI_SUPPORT_DATA
partition SYS_P2283 values less than (TO_DATE(' 2010-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
tablespace BI_SUPPORT_DATA
pctfree 10
initrans 1
maxtrans 255
subpartition SYS_SUBP2279 tablespace BI_SUPPORT_DATA,
subpartition SYS_SUBP2280 tablespace BI_SUPPORT_DATA,
subpartition SYS_SUBP2281 tablespace BI_SUPPORT_DATA,
subpartition SYS_SUBP2282 tablespace BI_SUPPORT_DATA
partition SYS_P2278 values less than (TO_DATE(' 2010-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
tablespace BI_SUPPORT_DATA
pctfree 10
initrans 1
maxtrans 255
subpartition SYS_SUBP2274 tablespace BI_SUPPORT_DATA,
subpartition SYS_SUBP2275 tablespace BI_SUPPORT_DATA,
subpartition SYS_SUBP2276 tablespace BI_SUPPORT_DATA,
subpartition SYS_SUBP2277 tablespace BI_SUPPORT_DATA
);Edited by: user5716448 on 22-Mar-2013 04:49you can not move composite parition directly you need to move subpartition using this statments
alter table <tablename> move subpartition <sub partition name > tablespace <tablespace name>;
than change partition tablespace using
ALTER TABLE <table name> MODIFY DEFAULT ATTRIBUTES FOR PARTITION <partition name> TABLESPACE <tablespace name>;
Maybe you are looking for
-
How can you lock the screen on iPhone in iOS 7 while talking on the phone?
I am struggling to figure out how to lock the screen of my iPhone 5 during a phone call. In iOS 6, I was able to push the top "on/off" button to lock the screen. In iOS 7, I am able to do this ONLY while using the speakerphone. If I push this button
-
What are the SAP standard programs?
Hi PM Guys, I have a question that is as below:- We have the following Master Data: 1) Functional Location 2) Equipment 3) Equipment BOM 4) Counter 5) Catalog Profiles 6) Task List a) General Task List b) Equipment Task List 7) Maintenance Plans a) T
-
Telstra 4G My Pocket Wi-Fi Plus not showing up in devices list of local Wi-Fi networks
Hi All, I purchased a 'Telstra 4G My Pocket Wi-Fi Plus' approximately 10 days ago. The device has been functioning perfectly up until 2 nights ago. The mobile WiFi network is no longer appearing as a WiFi option on any of my or my friends mobile phon
-
Hi Basis Gurus, I have a small doubt regarding Background jobs. Can we edit a job which is in the Scheduled status. . If that can be done , i am unable to edit a job . When i am trying to edit the job the message i am gettin
-
Hi all, I have Windows XP and Fedora Core Project 1 on my PC. I am trying to learn JSP and JDBC. I am using Wrox's Professional JSP book for reference. I was able to executed the code successfully on Windows XP with SQL Server 2000 as database. I tri