Convert range partition to range-hash composite partition
Hi,
I have several tables that are range partitioned on date and each table has several partitions as they are partitioned for each day. Is there anyway I con convet these table using alter statements to make them a composite? Thanks.
No, You can't with alter command change partitioning type.
http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10739/partiti.htm
Create a new table with needed one partitioning type and insert there all data.
Similar Messages
-
Hi,
I am on Oracle 11gR2.
I am trying to create a table with list hash composite partitioning. List partition will be on a numeric column and hash partition will be on a varchar2 column and will contain alphanumeric data.
It looks like while creating hash subpartition I have provide values clause. The varchar2 column will have a unique value for each record so I am not sure what should I provide in values clause?
Is there a way to create hash subpartition without using values clause and just specifying number of subpartitions?
Appreciate your help.
Thanks>
Considering performance issues, I am looking at using Oracle Parallelism. My understanding is that good partitioning strategy will lead to better use of parallelism.
>
First, and foremost, try to understand this: you DO NOT have a performance issue. Period!
You appear to be trying to create an architecture and implementation based on an assumption that you will have a performance issue. That is the wrong approach to use. You need to design the system first and then implement it. You have already made up your mind that you are going to
1. use external tables
2. use two work tables
3. add an additional column which will be unique for each record to both load tables and populate that load table at the time of import
4. partition the two work tables - not just using list partitioning but you already know that you want hash subpartitioning
5. load a third table by joining the two work tables to other tables
6. and you seem to know that there will definitely be a FTS
You must really be psychic to know that all of those things are needed or will happen before you even have a working prototype.
You have the entire thing backwards. You already know what solution you want to impose (adding columns, using composite partitioning, using external tables) and you don't even have the problem and process documented completely.
If it ain't broke, don't fix it. Until you have a demonstrated performance problem don't try to solve it; it doesn't exist yet and may never exist.
The first step is to design a process that gets the job done. This design stage does not involve implementation-related considerations. Design is all about WHAT needs to be done not HOW to do it.
1. Identify the data sources (source tables and columns)
2. Identify the transformations that need to be performed (data cleansing, surrogate key generation, etc)
3. Identify the data targets (target tables and columns
4. Identify the error handling that needs to be implemented: how to recover if things go wrong, what to do with bad or missing data
5. Determine how to validate that the ETL process produced the correct results.
Only after you have determined and documented the requirements should you proceed to the next step.
That next step might be a proof-of-concept. If so you want to do the minimum amount of work that proves that the 'process' is correct and that you haven't overlooked anything. This means creating simple basic tables that you can load with data. Then you can run some manual audit queries to see what kind of data you are dealing with: do any columns have null values that shouldn't, do all varchar2 columns that are supposed to contain date strings or numbers really contain date strings or numbers?
You need to get a prototype working and know how many records you are dealing with and how they need to be joined to all of those other tables with the millions of records. Then you will have a better idea as to whether there COULD BE a performance or other issue that needs to be dealt with.
>
After import, I will have to load data from these 2 tables (all columns for both tables) into a third table. Lets call this table as t_test_stg.
t_test_stg will have columns from t_file1_lod and t_file2_lod.
Now the issue is that there is no key column in t_file1_lod and t_file2_lod that can be used to join the two tables. Only other way to match columns in 2 load tables is by joining other tables and all these tables
have atleast 80-100 million records. So there will definitely be a FTS,
>
Your architecture doesn't make sense for what you say you are trying to do.
If you need to join the two load tables using other tables you don't want to use list and hash partitioning. That will just randomly distribute the data from each file that you need to join to those other tables.
Assuming that partitioning is even needed (which I doubt) the data needs to be partitioned in a way to make those joins to those other tables efficient. Until you know what those joins are and what the cardinality of the (as yet unknown) predicates are you can't possibly choose the proper partitioning scheme.
Simple is better. Finish the design. Conduct a verbal walkthrough of that design with your co-workers (and the business users) to identify any gaps. Implement a SIMPLE prototype that proves that the PROCESS is correct (the process - not the specific implementation of that process.
Then, and only then, should you start the design and implementation of the actual data model that you expect to use.
Sit down. Take a deep breath. And start over from the beginning. -
I have a table into which data is inserted daily and contain customer nos. Most of the queries contain where clauses with customer no. field and date field.
I am looking for some suggestions on the type table to be created (IOT or Normal) and also the partitioning options, hash/range on date/customer no or composite partitioning. Range partitioning on date is an obvious solution but the table may need maintantance in the future creating new partitions.You didn't specify Which oracle version and OS you are using. How can we know that what you are running and your table structure.
Also, your buffer busy waits are culprit and this might due to index range scan happening for every insert. But this is a guess -
Any practical experience with composite partitioning range/list?
Hi,
I'm working on Oracle 9.2.0.4 and I plan to migrate several large range partitioned tables into range/list partitioned tables. I was wondering I anybody has some practical experience with this new feature (range/list composite partitioning) and if he encountered any bugs or "undocumented features" ?
Thanks for any feedback
Maurcie
PS: I'm not looking for any documentation about how to do it, I'm just wondering if anyone has some experience in a PRODUCTIVE environment.You can also put the query in a parameter file so you don't have to worry about escaping characters.
Dean -
Determine partition range start and stop for a partition
Hi,
Using oracle 11.2.0.3
We are using range interval partitioning and partition sget generated automatically. (range-hash) intervbal 1 month
Whilst can check table manually and see start and end range of partition is it possible to query data dictionary to see
the satrt and stop range as wish to have script to automatically rename the system generated partitions based on the range involved e.g if generated partition has max date value
3062013 waoul want PART_201306
ThanksThanks for replies.
Have triied following sql but despite partition keyword in from clause is not using partition pruning.
Table belwo retailer_transaction date-range partitioned 1 per month.
If have to explictly use partitiong_date as condition in where clause to get partition pruning.
Need to ab able to determine what start and stop dates for that month is automatically.
Checked user_tab_partitions as have sql geneerator can get partition names but doesn't show partition start an dstop ranges.
How can I achieve this
sql gneerator starts
for p in
( select U.PARTITION_NAME
from ALL_tab_partitions u
where u.table_name = 'RETAILER_TRANSACTION'
and u.partition_name = 'PART_201001'
loop
v_sql := q'[create table rt_sum_]'||p.partition_name||q'[ parallel nologging
as
SELECT
MAX(rt.outlet_id) KEEP (DENSE_RANK FIRST ORDER BY c.day_dte) as outlet_id,
MAX(rt.plant_issue_id) KEEP (DENSE_RANK FIRST ORDER BY c.day_dte) as plant_issue_id,
MAX(rt.cus_plant_id) KEEP (DENSE_RANK FIRST ORDER BY c.day_dte) as cus_plant_id,
MAX(rt.distributor_id) KEEP (DENSE_RANK FIRST ORDER BY c.day_dte) as distributor_id,
MAX(rt.publisher_id) KEEP (DENSE_RANK FIRST ORDER BY c.day_dte) as publisher_id,
MAX(rt.sas_id) KEEP (DENSE_RANK FIRST ORDER BY c.day_dte) as sas_id,
MAX(rt.product_band_id) KEEP (DENSE_RANK FIRST ORDER BY c.day_dte) as product_band_id,
MAX(r.mult_id) KEEP (DENSE_RANK FIRST ORDER BY c.day_dte) as mult_id,
r.out_num,
m.plis_issue_num,
min(rt.currency_id) currency_id, -- to fix cutover prob if mix £ and E then forces to E
max(rt.currency_convertor_id) currency_convertor_id,
sum(case when rtrt.TYP_MAIN_SUPPLY_FLAG = 1 then rt.TRANSACTION_QUANTITY ELSE 0 end) main_supply,
sum(case when rtrt.TYP_COPIES_INVOICED_FLAG = 1 then rt.TRANSACTION_QUANTITY ELSE 0 end) -
sum(case when rtrt.TYP_MAIN_SUPPLY_FLAG = 1 then rt.TRANSACTION_QUANTITY ELSE 0 end) extra_supply,
sum(case when rtrt.TYP_COPIES_INVOICED_FLAG = 1 then rt.TRANSACTION_QUANTITY ELSE 0 end) SALES,
sum(case when rtrt.TYP_RETURN_FLAG = 1 then rt.TRANSACTION_QUANTITY ELSE 0 end) RETURNS,
sum(case when rtrt.TYP_CREDIT_FLAG = 1 then rt.TRANSACTION_QUANTITY ELSE 0 end) CREDITS,
sum(case when rtrt.TYP_RETURN_FLAG = 1 AND c.day_dte < m.plis_recall_date then rt.TRANSACTION_QUANTITY ELSE 0 end) early_returns,
sum(case when rtrt.TYP_CRD_MANAGER_CREDIT_FLAG = 1 then rt.TRANSACTION_QUANTITY ELSE 0 end) managers_credit_qty, -- TO CHECK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
decode(sign(sum(case when rtrt.TYP_CREDIT_FLAG = 1 then rt.TRANSACTION_QUANTITY ELSE 0 end)),1,null,( case when sysdate < max(m.plis_claim_end_date) then 'P' ELSE 'Y' end )) sellout_type, -- null= not soldout, 'P'= potential sellout, 'Y'=Sellout (flag based on claim end date)
-- retail
sum(case when rtrt.TYP_COPIES_INVOICED_FLAG = 1 then rt.retail_value_excl_vat ELSE 0 end) retail_inv_val_excl_vat,
sum(case when rtrt.TYP_COPIES_INVOICED_FLAG = 1 then rt.retail_value_vat ELSE 0 end) retail_inv_val_vat,
sum(case when rtrt.TYP_RETURN_FLAG = 1 then rt.retail_value_excl_vat ELSE 0 end) retail_ret_val_excl_vat,
sum(case when rtrt.TYP_RETURN_FLAG = 1 then rt.retail_value_vat ELSE 0 end) retail_ret_val_vat,
sum(case when rtrt.TYP_CREDIT_FLAG = 1 then rt.retail_value_excl_vat ELSE 0 end) retail_crd_val_excl_vat,
sum(case when rtrt.TYP_CREDIT_FLAG = 1 then rt.retail_value_vat ELSE 0 end) retail_crd_val_vat,
-- trade
sum(case when rtrt.TYP_COPIES_INVOICED_FLAG = 1 then rt.trade_value_excl_vat ELSE 0 end) trade_inv_val_excl_vat,
sum(case when rtrt.TYP_COPIES_INVOICED_FLAG = 1 then rt.trade_value_vat ELSE 0 end) trade_inv_val_vat,
sum(case when rtrt.TYP_RETURN_FLAG = 1 then rt.trade_value_excl_vat ELSE 0 end) trade_ret_val_excl_vat,
sum(case when rtrt.TYP_RETURN_FLAG = 1 then rt.trade_value_vat ELSE 0 end) trade_ret_val_vat,
sum(case when rtrt.TYP_CREDIT_FLAG = 1 then rt.trade_value_excl_vat ELSE 0 end) trade_crd_val_excl_vat,
sum(case when rtrt.TYP_CREDIT_FLAG = 1 then rt.trade_value_vat ELSE 0 end) trade_crd_val_vat,
-- cost
sum(case when rtrt.TYP_COPIES_INVOICED_FLAG = 1 then rt.cost_value_excl_vat ELSE 0 end) cost_inv_val_excl_vat,
sum(case when rtrt.TYP_COPIES_INVOICED_FLAG = 1 then rt.cost_value_vat ELSE 0 end) cost_inv_val_vat,
sum(case when rtrt.TYP_RETURN_FLAG = 1 then rt.cost_value_excl_vat ELSE 0 end) cost_ret_val_excl_vat,
sum(case when rtrt.TYP_RETURN_FLAG = 1 then rt.cost_value_vat ELSE 0 end) cost_ret_val_vat,
sum(case when rtrt.TYP_CREDIT_FLAG = 1 then rt.cost_value_excl_vat ELSE 0 end) cost_crd_val_excl_vat,
sum(case when rtrt.TYP_CREDIT_FLAG = 1 then rt.cost_value_vat ELSE 0 end) cost_crd_val_vat,
min(case when rtrt.TYP_COPIES_INVOICED_FLAG = 1 then rt.day_id ELSE null end) first_supply_day_id,
max(case when rtrt.TYP_COPIES_INVOICED_FLAG = 1 then rt.day_id ELSE null end) last_supply_day_id,
min(case when rtrt.TYP_RETURN_FLAG = 1 then rt.day_id ELSE null end) first_return_day_id,
max(case when rtrt.TYP_RETURN_FLAG = 1 then rt.day_id ELSE null end) last_return_day_id
FROM
dw.MEDIA m,
dw.RETAILER_TRN_REPORT_TYPE rtrt,
dw.RETAILER_TRANSACTION partition (]'||p.partition_name||q'[) rt,
dw.RETAILER r,
-- dw.WHOLESALER w,
dw.CALENDAR c
WHERE
--rt.CUS_PLANT_ID=w.DIMENSION_KEY
--AND
rt.OUTLET_ID=r.DIMENSION_KEY
AND rt.PLANT_ISSUE_ID = m.DIMENSION_KEY
AND rtrt.DIMENSION_KEY=rt.REPORTING_TRN_TYPE_ID
AND rt.DAY_ID=c.DIMENSION_KEY
--and rt.partitioning_date = m.plis_partitioning_date
-- and m.PLIS_HANDLED_YEAR = 2013--> 2011
group by
r.out_num,
m.plis_issue_num]';
EXECUTE IMMEDIATE(V_SQL);
INSERT INTO RTRN_PART_SUM_AUDIT
(PARTITION_NAME, DATE_CREATED)
VALUES(P.PARTITION_NAME, SYSDATE);
COMMIT;
end loop;
-
Partition by range using greater than or in between statment?
Can you partition by range using greater than or in between statment? If so, can someone please post the syntax?
ji**** wrote:
Can you partition by range using greater than or in between statment? If so, can someone please post the syntax?http://download.oracle.com/docs/cd/B10500_01/server.920/a96524/c12parti.htm
CREATE TABLE sales_range
(salesman_id NUMBER(5),
salesman_name VARCHAR2(30),
sales_amount NUMBER(10),
sales_date DATE)
PARTITION BY RANGE(sales_date)
PARTITION sales_jan2000 VALUES LESS THAN(TO_DATE('02/01/2000','DD/MM/YYYY')),
PARTITION sales_feb2000 VALUES LESS THAN(TO_DATE('03/01/2000','DD/MM/YYYY')),
PARTITION sales_mar2000 VALUES LESS THAN(TO_DATE('04/01/2000','DD/MM/YYYY')),
PARTITION sales_apr2000 VALUES LESS THAN(TO_DATE('05/01/2000','DD/MM/YYYY'))
); -
Change partitioned column range in range partioning in 11g
Hi All,
First of all , i am thankful to all of you for your help and suggestions in past. I have one new issue. I am using Oracle 11. There is one new functionality in 11g to do range paritioning while table creation and do daily partitioning.
CREATE TABLE TEST(
DUE_DAY DATE,
ID VARCHAR2(10 BYTE),
NAME VARCHAR2(25 BYTE)
PARTITION BY RANGE (DUE_DAY)
INTERVAL( NUMTODSINTERVAL(1,'DAY'))
PARTITION FIRST VALUES LESS THAN (TO_DATE('2012-02-05 12:00:00', 'SYYYY-MM-DD HH24:MI:SS')));
Now I found i create the partition range wrong so each partition has data from previous day 12:00 afternoon to today 12:00 afternoon instead of daily data from 00:00 am to 11:59 pm because i mentioned wrong range in partition.
I supposed to do like this:
CREATE TABLE TEST(
DUE_DAY DATE,
ID VARCHAR2(10 BYTE),
NAME VARCHAR2(25 BYTE)
PARTITION BY RANGE (DUE_DAY)
INTERVAL( NUMTODSINTERVAL(1,'DAY'))
PARTITION FIRST VALUES LESS THAN (TO_DATE('2012-02-05 00:00:00', 'SYYYY-MM-DD HH24:MI:SS')));
My question is: Is there any way i can change it now as table already has huge data in it, so i cant go with creation of another partitioned table with correct partition range? Please let me know your suggestions and comments to resolve this issue.
Regards
Dev
Edited by: Keen2Learn on Feb 10, 2012 9:12 AMKeen2Learn wrote:
My question is: Is there any way i can change it now as table already has huge data in it, so i cant go with creation of another partitioned table with correct partition range? Please let me know your suggestions and comments to resolve this issue.Nope.
I don't think it is possible to achieve this without creating a new/an intermediate table.
If you can afford down-time, you should create new table, load data into it (in parallel with nologging), drop original table and rename new table.
If you want this switchover as online operation, you can use DBMS_REDEFINITION as follows:
SQL> select * from v$version ;
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
SQL> CREATE TABLE TEST(
2 DUE_DAY DATE,
3 ID VARCHAR2(10 BYTE),
4 NAME VARCHAR2(25 BYTE)
5 )
6 PARTITION BY RANGE (DUE_DAY)
7 INTERVAL( NUMTODSINTERVAL(1,'DAY'))
8 (
9 PARTITION FIRST VALUES LESS THAN (TO_DATE('2012-02-01 12:00:00', 'SYYYY-MM-DD HH24:MI:SS')));
Table created.
SQL> insert into test(due_day, id) select (trunc(sysdate, 'MM')+(10/24)) + ((5*level)/24), level from dual connect by level <= 12 ;
12 rows created.
SQL> commit ;
Commit complete.
SQL> exec dbms_stats.gather_table_stats(user, 'TEST');
PL/SQL procedure successfully completed.
SQL> select partition_name, num_rows from user_tab_partitions where table_name = 'TEST' ;
PARTITION_NAME NUM_ROWS
FIRST 0
SYS_P115 5
SYS_P116 4
SYS_P117 3
SQL> SELECT * FROM TEST PARTITION (FIRST) ;
no rows selected
SQL> SELECT * FROM TEST PARTITION (SYS_P115) ;
DUE_DAY ID NAME
01-FEB-2012 15:00:00 1
01-FEB-2012 20:00:00 2
02-FEB-2012 01:00:00 3
02-FEB-2012 06:00:00 4
02-FEB-2012 11:00:00 5
SQL> SELECT * FROM TEST PARTITION (SYS_P116);
DUE_DAY ID NAME
02-FEB-2012 16:00:00 6
02-FEB-2012 21:00:00 7
03-FEB-2012 02:00:00 8
03-FEB-2012 07:00:00 9
SQL> SELECT * FROM TEST PARTITION (SYS_P117);
DUE_DAY ID NAME
03-FEB-2012 12:00:00 10
03-FEB-2012 17:00:00 11
03-FEB-2012 22:00:00 12
SQL> exec DBMS_REDEFINITION.CAN_REDEF_TABLE('hr','TEST',DBMS_REDEFINITION.CONS_USE_ROWID);
PL/SQL procedure successfully completed.
SQL> CREATE TABLE INTR_TEST(
2 DUE_DAY DATE,
3 ID VARCHAR2(10 BYTE),
4 NAME VARCHAR2(25 BYTE)
5 )
6 PARTITION BY RANGE (DUE_DAY)
7 INTERVAL( NUMTODSINTERVAL(1,'DAY'))
8 (
9 PARTITION FIRST VALUES LESS THAN (TO_DATE('2012-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS')));
Table created.
SQL> exec DBMS_REDEFINITION.START_REDEF_TABLE('hr', 'TEST', 'INTR_TEST', 'due_day due_day, id id, name name', dbms_redefinition.cons_use_rowid);
PL/SQL procedure successfully completed.
SQL> exec DBMS_REDEFINITION.SYNC_INTERIM_TABLE('hr', 'TEST', 'INTR_TEST');
PL/SQL procedure successfully completed.
SQL> exec DBMS_REDEFINITION.FINISH_REDEF_TABLE('hr', 'TEST', 'INTR_TEST');
PL/SQL procedure successfully completed.
SQL> exec dbms_stats.gather_table_stats(user, 'TEST');
PL/SQL procedure successfully completed.
SQL> select partition_name, num_rows from user_tab_partitions where table_name = 'TEST' ;
PARTITION_NAME NUM_ROWS
FIRST 0
SYS_P118 2
SYS_P119 5
SYS_P120 5
SQL> SELECT * FROM TEST PARTITION (FIRST) ;
no rows selected
SQL> SELECT * FROM TEST PARTITION (SYS_P118) ;
DUE_DAY ID NAME
01-FEB-2012 15:00:00 1
01-FEB-2012 20:00:00 2
SQL> SELECT * FROM TEST PARTITION (SYS_P119);
DUE_DAY ID NAME
02-FEB-2012 01:00:00 3
02-FEB-2012 06:00:00 4
02-FEB-2012 11:00:00 5
02-FEB-2012 16:00:00 6
02-FEB-2012 21:00:00 7
SQL> SELECT * FROM TEST PARTITION (SYS_P120);
DUE_DAY ID NAME
03-FEB-2012 02:00:00 8
03-FEB-2012 07:00:00 9
03-FEB-2012 12:00:00 10
03-FEB-2012 17:00:00 11
03-FEB-2012 22:00:00 12
SQL> select dbms_metadata.get_ddl('TABLE','TEST') from dual ;
DBMS_METADATA.GET_DDL('TABLE','TEST')
CREATE TABLE "HR"."TEST"
( "DUE_DAY" DATE,
"ID" VARCHAR2(10),
"NAME" VARCHAR2(25)
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
STORAGE(
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "USERS"
PARTITION BY RANGE ("DUE_DAY") INTERVAL (NUMTODSINTERVAL(1,'DAY'))
(PARTITION "FIRST" VALUES LESS THAN (TO_DATE(' 2012-02-01 00:00:00', 'SYYYY-MM
-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')) SEGMENT CREATION DEFERRED
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE( BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "USERS" )
SQL> drop table intr_test purge ;
Table dropped.
SQL> drop table test purge ;
Table dropped.
SQL> spool offHope this helps. -
I have a table which is partitioned as follows:
PARTITION BY RANGE (CALL_TIME_MONTH, RECORD_TYPE)
PARTITION PARTITION_200309_MOC VALUES LESS THAN ('200309', 2)
NOLOGGING
TABLESPACE POST_CDR_200309_MOC
How is it possible that this partition holds data of 200309 (and not 200308) ???!?:
select min(CALL_TIME_MONTH), max(CALL_TIME_MONTH) from my_table partition (PARTITION_200309_MOC)
200309, 200309CREATE TABLE POST_CDR
ID NUMBER NOT NULL,
ENTRY_DATE DATE NOT NULL,
RECORD_TYPE NUMBER,
CALL_TIME_MONTH VARCHAR2(6 BYTE) NOT NULL,
FNAME VARCHAR2(100 BYTE),
FILE_ID NUMBER
NOLOGGING
TABLESPACE POST_CDR_MAIN
PARTITION BY RANGE (CALL_TIME_MONTH, RECORD_TYPE)
PARTITION PARTITION_200406_MOC VALUES LESS THAN ('200406', MAXVALUE)
NOLOGGING
TABLESPACE POST_CDR_200406_MOC
PARTITION PARTITION_200406_MTC VALUES LESS THAN ('200406', MAXVALUE)
NOLOGGING
TABLESPACE POST_CDR_200406_MTC
PARTITION PARTITION_200407_MOC VALUES LESS THAN ('200407', 2)
NOLOGGING
TABLESPACE POST_CDR_200407_MOC
PARTITION PARTITION_200407_MTC VALUES LESS THAN ('200407', MAXVALUE)
NOLOGGING
TABLESPACE POST_CDR_200407_MTC
PARTITION PARTITION_200408_MOC VALUES LESS THAN ('200408', 2)
NOLOGGING
TABLESPACE POST_CDR_200408_MOC
PARTITION PARTITION_200408_MTC VALUES LESS THAN ('200408', MAXVALUE)
NOLOGGING
TABLESPACE POST_CDR_200408_MTC -
Partition by Range(c1,c2) and have c1 to be MAXVALUE for a specific c2
I have a table where two of the columns are used for PARTITION BY RANGE(C1,C2). Is it possible to have a partition scheme where for a specific c2, c1 can be MAXVALUE? The number of records of for a specific C2 are very few and I would like to have just one partition for all C1 values.
>
I have a table where two of the columns are used for PARTITION BY RANGE(C1,C2). Is it possible to have a partition scheme where for a specific c2, c1 can be MAXVALUE? The number of records of for a specific C2 are very few and I would like to have just one partition for all C1 values.
>
If you want one partition for all C1 values for a particular C2 then you need to reverse the order of the partition keys and use PARTITION BY RANGE(C2, C1).
drop table myTable cascade constraints;
CREATE TABLE myTable (c1 number, c2 number, description varchar2(30))
PARTITION BY RANGE (C2, C1)
(PARTITION p_before3_5 VALUES LESS THAN (3, 5),
PARTITION p3_5_to_4_5 VALUES LESS THAN (4,5),
PARTITION p4_5_to_5 VALUES LESS THAN (5,maxvalue),
PARTITION p_special_6 VALUES LESS THAN (7,0),
PARTITION future VALUES LESS THAN (MAXVALUE,0));
insert into myTable (c2, c1) values (5, 3);
insert into myTable (c2, c1) values (6, 3);
insert into myTable (c2, c1) values (6, 8);
insert into myTable (c2, c1) values (7, 3);
select * from mytable partition (p_special_6);
C1,C2,DESCRIPTION
3,6,
8,6,The 'p_special_6' partition captures everything for C2 = 6 assuming that the min value of c1 is 0. Note that the previous partition has to be defined as '(5, maxvalue)' to capture everything less than C2 = 6.
See Example 4-21 Creating a multicolumn range-partitioned table in the doc link already provided for other examples. -
TIMESTAMP(6) Partitioned Key - Range partitioned table ddl needed
What is DDL syntax for TIMESTAMP(6) Partitioned Key, Range partitioned table
Edited by: oracletune on Jan 11, 2013 10:26 AM>
What is DDL syntax for TIMESTAMP(6) Partitioned Key, Range partitioned table
>
Not sure what you are asking. Are you asking how to create a partitioned table using a TIMESTAMP(6) column for the key?
CREATE TABLE TEST1
USERID NUMBER,
ENTRYCREATEDDATE TIMESTAMP(6)
PARTITION BY RANGE (ENTRYCREATEDDATE) INTERVAL(NUMTOYMINTERVAL(1, 'MONTH'))
PARTITION P0 VALUES LESS THAN (TO_DATE('1-1-2013', 'DD-MM-YYYY'))
)See my reply Posted: Jan 10, 2013 9:56 PM if you need to do it on a TIMESTAMP with TIME ZONE column. You need to add a virtual column.
Creating range paritions automatically -
Hi folks.
We need create a new table with partition. Today this table already exist and we will recreate with partition.
The table have a VARCHAR column, that the application insert the data in this format -->YYYYMMDDHH24MISS.
For example --> 20120812000000.
This data is a "date" but insert in a VARCHAR2 column.
Can we create the table with range partition using this VARCHAR2 column, and make control of a Range partition by week, month. ?
TksDon't be afraid of breaking Oracle by actually trying things.
And you can't break the documentation by reading it.
http://docs.oracle.com/cd/B28359_01/server.111/b32024/partition.htm#sthref34
>
Range Partitioning
Range partitioning maps data to partitions based on ranges of values of the partitioning key that you establish for each partition. It is the most common type of partitioning and is often used with dates. For a table with a date column as the partitioning key, the January-2005 partition would contain rows with partitioning key values from 01-Jan-2005 to 31-Jan-2005.
Each partition has a VALUES LESS THAN clause, which specifies a non-inclusive upper bound for the partitions. Any values of the partitioning key equal to or higher than this literal are added to the next higher partition. All partitions, except the first, have an implicit lower bound specified by the VALUES LESS THAN clause of the previous partition.
A MAXVALUE literal can be defined for the highest partition. MAXVALUE represents a virtual infinite value that sorts higher than any other possible value for the partitioning key, including the NULL value. -
Change partition by range column
Hi,
is it possible (oracel 11g) to change partition by range column for a table without recreating the whole table ?
now i have it : partition by range (COLUMN_A)
i need it : partition by range (COLUMN_B)
ThanksYes
Demos: http://www.morganslibrary.org/reference/partitions.html#rp
Look at the section titled: "Alter Table For Partitions" -
Problem exchanging partitions using range partitioning
I have a range-partitioned table. Here's a cut down version....
CREATE TABLE MY_TABLE
( VALUE NUMBER,
PARTITION_KEY NUMBER
PARTITION BY RANGE ("PARTITION_KEY")
(PARTITION "P1" VALUES LESS THAN (2),
PARTITION "P2" VALUES LESS THAN (3),
PARTITION "P3" VALUES LESS THAN (4),
PARTITION "P4" VALUES LESS THAN (5),
PARTITION "P5" VALUES LESS THAN (6),
PARTITION "P6" VALUES LESS THAN (7),
PARTITION "P7" VALUES LESS THAN (8));For the process I'm working on, I want to be able to:
- create a table as a copy of one of the partitions
- do some processing on that table
- exchange the updated table back into the partitioned table
I can achieve this as follows....
CREATE TABLE MY_TABLE_COPY_P7 AS (SELECT * FROM MY_TABLE WHERE PARTITION_KEY = 7);
... do processing ...
ALTER TABLE MY_TABLE DROP PARTITION P7;
ALTER TABLE MY_TABLE ADD PARTITION P7 VALUES LESS THAN (8);
ALTER TABLE MY_TABLE EXCHANGE PARTITION P7 WITH TABLE MY_TABLE_COPY INCLUDING INDEXES;However, this only works if the partition I'm adding back in is the highest partition.
If I try do take out one of the middle partitions, then add it back I get an error:
SQL] ALTER TABLE MY_TABLE ADD PARTITION P5 VALUES LESS THAN (6);
ALTER TABLE MY_TABLE ADD PARTITION P5 VALUES LESS THAN (6)
ERROR at line 1:
ORA-14074: partition bound must collate higher than that of the last partitionAny ideas on how I can exchange one of the middle partitions with having to first drop the higher ones?
Btw, I have to use range partitioning as we're using spatial, which only supports range partitioning.
Cheers,Actually, you can do the exchange partition thing with 8i and over. After creating my_table from your script, I did:
SQL> INSERT INTO my_table VALUES (1,7.5);
1 row created.
SQL> INSERT INTO my_table VALUES (2, 7.2);
1 row created.
SQL> INSERT INTO my_table VALUES (3,7.7);
1 row created.
SQL> CREATE TABLE my_tab_tmp AS
2 SELECT * FROM my_table
3 WHERE 1=2;
Table created.
SQL> ALTER TABLE my_table EXCHANGE PARTITION P7 WITH TABLE my_tab_tmp;
Table altered.
SQL> SELECT * FROM my_tab_tmp;
VALUE PARTITION_KEY
1 7.5
2 7.2
3 7.7
SQL> SELECT * FROM my_table;
no rows selected
SQL> UPDATE my_tab_tmp
2 set value = value * 20;
3 rows updated.
SQL> COMMIT;
Commit complete.
SQL> ALTER TABLE my_table EXCHANGE PARTITION P7 WITH TABLE my_tab_tmp;
Table altered.
SQL> SELECT * FROM my_tab_tmp;
no rows selected
SQL> SELECT * FROM my_table;
VALUE PARTITION_KEY
20 7.5
40 7.2
60 7.7You will, of course, need to re-build any global indexes on my_table.
When you first create my_tab_tmp, you should also create indexes to match any local indexes on the partitions, then do the exchange partition using the INCLUDING INDEXES clause. You could also skip creating the indexes and then re-create them after exchanging the updated table with the partition.
Note that none of this will work if you are changing values of partition_key so thatthey fall out of the range for the partition.
HTH
John -
[ask] change value partition by range
hi
i create table partition by range
CREATE TABLE EQU_PARAM_MONITORINGRANGE
SERIAL_NO VARCHAR2(32 BYTE),
ID_EQU_PARAMETER INTEGER,
TIME_STAMP DATE,
VALUE FLOAT(126)
PARTITION BY RANGE (ID_EQU_PARAMETER)
PARTITION PARAM_RANGE1 VALUES LESS THAN (18)
PARTITION PARAM_RANGE2 VALUES LESS THAN (36)
PARTITION PARAM_RANGE3 VALUES LESS THAN (MAXVALUE)
)and i want to change partition_range1 under 16,how to change it??You do it like this:
SQL> select PARTITION_NAME, HIGH_VALUE from user_tab_partitions where table_name = 'EQU_PARAM_MONITORINGRANGE';
PARTITION_NAME HIGH_VALUE
PARAM_RANGE1 18
PARAM_RANGE2 36
PARAM_RANGE3 MAXVALUE
SQL> alter table EQU_PARAM_MONITORINGRANGE split partition PARAM_RANGE1 at (16) into (partition PARAM_RANGE1a, partition PARAM_RANGE1b);
Table altered.
SQL> select PARTITION_NAME, HIGH_VALUE from user_tab_partitions where table_name = 'EQU_PARAM_MONITORINGRANGE';
PARTITION_NAME HIGH_VALUE
PARAM_RANGE2 36
PARAM_RANGE3 MAXVALUE
PARAM_RANGE1A 16
PARAM_RANGE1B 18
SQL> alter table EQU_PARAM_MONITORINGRANGE drop partition PARAM_RANGE1B;
Table altered.
SQL> select PARTITION_NAME, HIGH_VALUE from user_tab_partitions where table_name = 'EQU_PARAM_MONITORINGRANGE';
PARTITION_NAME HIGH_VALUE
PARAM_RANGE2 36
PARAM_RANGE3 MAXVALUE
PARAM_RANGE1A 16
SQL>Make sure to rebuild all global indexes.
Asif Momen
http://momendba.blogspot.com -
Moving Composite Partition table
Hi,
i am using 11.2.0.3.0 version of oracle. I am planning to move a composite partition(range-hash) table into a different tablespace. And i was under assumption by moving the table/index subpartition , it will move the wholw table. Below is the scenario.
Now i have moved all the table/Index subpartition into the new tablespace, using below command.
Alter table t1 move subpartition t1_sub1 tablespace new_tablespace;
Alter index id1 rebuild subpartition id1_sub1 tablespace new_ind1_tablespace;
but when i query dba_tab_subpartition i can see the new tablespace against the subpartition name but when i query the data dictionary dba_tab_partitions i am seeing the name of old tablespace against the partition name. And i execute below statement for moving the partition
Alter table t1 move partition t1_p1 tablespace new_tablespace;
It gives error saying : ORA-14257: cannot move partition other than a range,list,system or hash partition.933257 wrote:
Hi,
i am using 11.2.0.3.0 version of oracle. I am planning to move a composite partition(range-hash) table into a different tablespace. And i was under assumption by moving the table/index subpartition , it will move the wholw table. Below is the scenario.
Now i have moved all the table/Index subpartition into the new tablespace, using below command.
Alter table t1 move subpartition t1_sub1 tablespace new_tablespace;
Alter index id1 rebuild subpartition id1_sub1 tablespace new_ind1_tablespace;
but when i query dba_tab_subpartition i can see the new tablespace against the subpartition name but when i query the data dictionary dba_tab_partitions i am seeing the name of old tablespace against the partition name. And i execute below statement for moving the partition
Alter table t1 move partition t1_p1 tablespace new_tablespace;
It gives error saying : ORA-14257: cannot move partition other than a range,list,system or hash partition.
Notice that PARTITION & SUBPARTITION are separate object; which need to be moved independently
06:46:11 SQL> SELECT OBJECT_TYPE, COUNT(*) FROM DBA_OBJECTS GROUP BY OBJECT_TYPE ORDER BY 1;
OBJECT_TYPE COUNT(*)
CLUSTER 10
CONSUMER GROUP 25
CONTEXT 7
DESTINATION 2
DIMENSION 5
DIRECTORY 9
EDITION 2
EVALUATION CONTEXT 14
FUNCTION 309
INDEX 4502
INDEX PARTITION 406
OBJECT_TYPE COUNT(*)
INDEXTYPE 9
JAVA CLASS 22945
JAVA DATA 303
JAVA RESOURCE 840
JAVA SOURCE 6
JOB 18
JOB CLASS 14
LIBRARY 185
LOB 1367
LOB PARTITION 1
MATERIALIZED VIEW 3
OBJECT_TYPE COUNT(*)
OPERATOR 55
PACKAGE 1445
PACKAGE BODY 1385
PROCEDURE 176
PROGRAM 19
QUEUE 45
RESOURCE PLAN 10
RULE 1
RULE SET 23
SCHEDULE 3
SCHEDULER GROUP 4
OBJECT_TYPE COUNT(*)
SEQUENCE 264
SYNONYM 28070
TABLE 3144
TABLE PARTITION 246
TABLE SUBPARTITION 32
TRIGGER 731
TYPE 2891
TYPE BODY 237
UNDEFINED 11
VIEW 5261
WINDOW 9
OBJECT_TYPE COUNT(*)
XML SCHEMA 58
45 rows selected.
06:46:49 SQL>
Maybe you are looking for
-
What is the best way to keep a MacBook Pro backed up?
I'm about to buy a MacBook Pro for my daughter who is about to start University. She will need to back up her work of course, so I'm wondering what is the best way to back up a MacBook? At home I have my iMac which is backed up to a WD Studio II 2TB
-
How do I export full conversations in apple mail
Sometimes conversations in Mail provide a quick diary of business and personal events. Is there anyway to export a bunch of emails, all at once, into a pdf or text file?
-
Integrating WebSphere Portal Server with Sun Java System Access Manager
Hi All, Is it possible to Integrate WebSphere Portal Server with Sun java System Access Manager?. If so plz send me any doc or web site link for the same. Thanks in Advance Rgds, Lessly J
-
Strange issue with Multi-Table LTS and report filters (10g)
Hi, I am having some troubles with the following scenario: I have a large flattened table that is being used as both Fact and Dimension in the BMM layer. I also have another table that contains some supplementary measures needed by some reports. Logi
-
I need to reinstall 10.1
Is there anyway I can do this.