Oracle Exchange partition Example

October 6th, 2010 | Posted in Blog, oracle partitioning | 3 Comments

   



Please select your language

This article presents a simple method for partitioning an existing table using the EXCHANGE PARTITION syntax.
EXCHANGE PARTITION is also an easy and fast way to copy data from NON Partitioned table to a Partitioned one. Both tables should have the same definition (Columns orders, names and types).

DROP TABLE PARTI_TABLE_1;
DROP TABLE PARTI_TABLE_2;
CREATE TABLE PARTI_TABLE_1
—- the destinationTable
(
CREA_MONTH VARCHAR2(6) ,
CREA_DAY VARCHAR2(8) ,
CREA_DATE DATE ,
DESC VARCHAR2(200) ,
ID NUMBER
)
partition by list (CREA_MONTH)
( partition PARTI_TABLE_201010 values (’201010′) tablespace USERS )

;

CREATE TABLE PARTI_TABLE_2
—- the Source Table
(

CREA_MONTH VARCHAR2(6) ,
CREA_DAY VARCHAR2(8) ,
CREA_DATE DATE ,
DESC VARCHAR2(200) ,
ID NUMBER
)
tablespace USERS NOLOGGING

;

INSERT INTO PARTI_TABLE_2 (CREA_MONTH,CREA_DAY,CREA_DATE,DESC,ID) VALUES (’201010′, ’20101001′, to_date(’20101001′,’YYYYMMDD’), ‘ABC’, 1);
COMMIT;

ALTER TABLE
—destination table
PARTI_TABLE_1
EXCHANGE PARTITION PARTI_TABLE_201010
WITH TABLE
—-Source data table
PARTI_TABLE_2
WITHOUT VALIDATION
UPDATE GLOBAL INDEXES;

SELECT * FROM PARTI_TABLE_1;

Nice reading,
Wissem

Cet artcile présente une simple méthode de partionnement d’une table déja existante en utilisant la syntaxe “EXCHANGE PARTITION”.
“EXCHANGE PARTITION” est aussi une méthode simple et rapide de copie de données d’une table source non partitionée vers une table partitionée.
Les deux tables doivent avoir la même définition ; structure des colonnes.
Example :
This article presents a simple method for partitioning an existing table using the EXCHANGE PARTITION syntax.
EXCHANGE PARTITION is also an easy and fast way to copy data from NON Partitioned table to a Partitioned one. Both tables should have the same definition (Columns orders, names and types).
DROP TABLE PARTI_TABLE_1;
DROP TABLE PARTI_TABLE_2;
CREATE TABLE PARTI_TABLE_1
—- the destinationTable
(
CREA_MONTH VARCHAR2(6) ,
CREA_DAY VARCHAR2(8) ,
CREA_DATE DATE ,
DESC VARCHAR2(200) ,
ID NUMBER
)
partition by list (CREA_MONTH)
( partition PARTI_TABLE_201010 values (’201010′) tablespace USERS )
;
CREATE TABLE PARTI_TABLE_2
—- the Source Table
(
CREA_MONTH VARCHAR2(6) ,
CREA_DAY VARCHAR2(8) ,
CREA_DATE DATE ,
DESC VARCHAR2(200) ,
ID NUMBER
)
tablespace USERS NOLOGGING
;
INSERT INTO PARTI_TABLE_2 (CREA_MONTH,CREA_DAY,CREA_DATE,DESC,ID) VALUES (’201010′, ’20101001′, to_date(’20101001′,’YYYYMMDD’), ‘ABC’, 1);
COMMIT;
ALTER TABLE
—destination table
PARTI_TABLE_1
EXCHANGE PARTITION PARTI_TABLE_201010
WITH TABLE
—-Source data table
PARTI_TABLE_2
WITHOUT VALIDATION
UPDATE GLOBAL INDEXES;
SELECT * FROM PARTI_TABLE_1;
Merci pour votre attention,
Wissem
Este article presenta un metodo sincillo de parttionar una tabla en Oracle usando el syntaxis “EXCHANGE PARTITION”.
“EXCHANGE PARTITION” un metodo sincillo y rapido de copa de datos desde une tabla fuente non partiticionada hacia una table partitionada.
Las dos tables tienen que ser de la misma estructua, misma definicion de las columnas.
Ejamplo :
This article presents a simple method for partitioning an existing table using the EXCHANGE PARTITION syntax.
EXCHANGE PARTITION is also an easy and fast way to copy data from NON Partitioned table to a Partitioned one. Both tables should have the same definition (Columns orders, names and types).
DROP TABLE PARTI_TABLE_1;
DROP TABLE PARTI_TABLE_2;
CREATE TABLE PARTI_TABLE_1
—- the destinationTable
(
CREA_MONTH VARCHAR2(6) ,
CREA_DAY VARCHAR2(8) ,
CREA_DATE DATE ,
DESC VARCHAR2(200) ,
ID NUMBER
)
partition by list (CREA_MONTH)
( partition PARTI_TABLE_201010 values (’201010′) tablespace USERS )
;
CREATE TABLE PARTI_TABLE_2
—- the Source Table
(
CREA_MONTH VARCHAR2(6) ,
CREA_DAY VARCHAR2(8) ,
CREA_DATE DATE ,
DESC VARCHAR2(200) ,
ID NUMBER
)
tablespace USERS NOLOGGING
;
INSERT INTO PARTI_TABLE_2 (CREA_MONTH,CREA_DAY,CREA_DATE,DESC,ID) VALUES (’201010′, ’20101001′, to_date(’20101001′,’YYYYMMDD’), ‘ABC’, 1);
COMMIT;
ALTER TABLE
—destination table
PARTI_TABLE_1
EXCHANGE PARTITION PARTI_TABLE_201010
WITH TABLE
—-Source data table
PARTI_TABLE_2
WITHOUT VALIDATION
UPDATE GLOBAL INDEXES;
SELECT * FROM PARTI_TABLE_1;Muchas gracias por su attencion,
Wissem

Scridb filter


3 Comments to “Oracle Exchange partition Example”

  1. maxim says:

    Hi.
    > Both tables should have the same definition (Columns orders, names and types).
    Column names of the exchanging tables can be different. I’m using oracle 10gr2.

  2. orawiss says:

    sure! Thanks for your comment

  3. Syed says:

    Nice Example.


Leave a Comment





Subscribe


Polls

which oracle topic interests you most?

View Results

Loading ... Loading ...


Oracle Class Tweets


Recent Posts


Recent Comments

  • Jaspreet: Brilliant explanation.
  • Yousuf: Very Nice… Just wanted to check you have done all patching at Node 1 only.. is there any thing need to...
  • Yousuf: Very Nice.. Thanks for sharing.. Once question.. You have executed all commands on Node 1 only.. Is there any...
  • Emir: Thanks… Great article
  • borse firmate: Thank you for another informative blog. The place else may just I am getting that kind of information...
  • leandro: why this parameter is systemwide? could you read from a asm instance from one failure group and from the...
  • Mohammad: paul, we create pfile from target database to source database and later we change database name, and...
  • Muhammad Ikram: Thanks Brother for sharing pearls of knowledge. May ALLAH reward you for this both here and...
  • rgrover: Thanks for the POST. I recently encounter similar issue. Your POST helped.
  • gopalredy: really its very use full to dbas
  • Vivian: This is awesome! Thank you so much!
  • henry zhong: CDB=DB, and PDB=SCHEMA but in a sub dictionary?
  • Dehbashee: Salam Brother, Thanx for sharing, however, i would be interested in chaging the password for the grid user...
  • wissem: No we don’t need that :) Just the scripts I posted above
  • Md. Tanweer: Thanks for posting the material. I really appreciate if you can send me, if you have tutorial for 11g...
  • christiaan: Thanks!! This has been bugging the hell out of me for so long.
  • Rajasekhar: Thank you
  • Samarjit Panigrahy: Very Nice and Simple Demo… Cool :)
  • cq: Any reason not to use auto patch for both CRS and RAC homes with one command? Or use opatch auto for RAC home as...
  • Hitesh: Hi, Can we use this RACcheck tool on oracle SE version ? Thanks