Your SlideShare is downloading. ×
DataPump ile Single Parititon Export
DataPump ile Single Parititon Export
DataPump ile Single Parititon Export
DataPump ile Single Parititon Export
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

DataPump ile Single Parititon Export

267

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
267
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
21
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Anar Godjaev http://anargodjaev.wordpress.com Oracle Data Pump ile Single parititon export/transport Oracle 11g ile birlikte single table partitionlarını veritabanları arasında taşımak mümkün hale gelmiştir, Normal olarak tablonun tamamını taşımaktansa sadece belli partition’unu taşımak çok daha mantıklıdır. Bunu örnekle dahada iyi açıklayabilmek adınapartititonlarımızı saklayacak 2 tane tablespace yaratacağız ve test açamçlı olarak bu tablespace ler üzerinde quotalar vereceğiz. [oracle@rac1 ~]$ sqlplus '/as sysdba' SQL>CREATE TABLESPACE transport_test_ts_1 DATAFILE 'tt_ts1.dbf' SIZE 128K AUTOEXTEND ON NEXT 128K; SQL>CREATE TABLESPACE transport_test_ts_2 DATAFILE 'tt_ts2.dbf' SIZE 128K AUTOEXTEND ON NEXT 128K; SQL>ALTER USER test QUOTA UNLIMITED ON transport_test_ts_1 QUOTA UNLIMITED ON transport_test_ts_2; SQL>CONN test/test Test kullanıcımızla bağlandıktan sonra örnek bir partition tablo yaratıyoruz ve içini veri ile dolduruyoruz. SQL>CREATE TABLE transport_test_tab ( id NUMBER NOT NULL, code VARCHAR2(10) NOT NULL, description VARCHAR2(50), created_date DATE, CONSTRAINT transport_test_pk PRIMARY KEY (id) ) PARTITION BY RANGE (created_date) ( PARTITION part_2010 VALUES LESS THAN (TO_DATE('01-10-2010','DD-MM-YYYY')) TABLESPACE transport_test_ts_1, PARTITION part_2011 VALUES LESS THAN (TO_DATE('01-10-2011','DD-MM-YYYY')) TABLESPACE transport_test_ts_2 ); SQL>INSERT INTO transport_test_tab SQL>INSERT INTO transport_test_tab SQL>INSERT INTO transport_test_tab ADD_MONTHS(SYSDATE,12)); SQL>INSERT INTO transport_test_tab ADD_MONTHS(SYSDATE,12)); SQL>COMMIT; VALUES (1, 'ONE', '1 ONE', SYSDATE); VALUES (2, 'TWO', '2 TWO', SYSDATE); VALUES (3, 'THREE', '3 THREE', VALUES (4, 'FOUR', '4 FOUR', Tablomuzun istatistiğini alıp ,tablomuza ait partitionları ve içerdikleri kayıtlara bir bakalım. SQL>EXEC DBMS_STATS.gather_table_stats(USER, 'TRANSPORT_TEST_TAB'); SQL>COLUMN table_name FORMAT A20 SQL>COLUMN partition_name FORMAT A20 SQL>COLUMN tablespace_name FORMAT A20
  • 2. Anar Godjaev http://anargodjaev.wordpress.com SQL> set linesize 1000 SQL>SELECT table_name, partition_name, tablespace_name, num_rows FROM user_tab_partitions Where table_name='TRANSPORT_TEST_TAB'; TABLE_NAME -------------------TRANSPORT_TEST_TAB TRANSPORT_TEST_TAB PARTITION_NAME -------------------PART_2010 PART_2011 TABLESPACE_NAME NUM_ROWS -------------------- ---------TRANSPORT_TEST_TS_1 2 TRANSPORT_TEST_TS_2 2 Görüldüğü gibi her partition 2 şer kayıt içeriyor. Transport yapacağımız tablespace ler kesinlikle readonly modda olmalıdır. SQL>ALTER TABLESPACE transport_test_ts_1 READ ONLY; Şu an herşey hazır 2010 parititonunu export yapabiliriz. [oracle@rac1 ~]$ sqlplus '/as sysdba' SQL> CREATE OR REPLACE DIRECTORY data_pump_dir AS '/u01/app11g/backup/'; SQL> GRANT READ, WRITE ON DIRECTORY data_pump_dir TO public; [oracle@rac1 ~]$expdp system/oracle tables=test.transport_test_tab:part_2010 transportable=always directory=data_pump_dir dumpfile=part_2010.dmp Yapılan export’un ouput’u aşağıdaki gibi olacaktır. Export: Release 11.2.0.1.0 - Production on Wed NOV18 13:35:17 2010 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Starting "SYSTEM"."SYS_EXPORT_TABLE_01": system/******** tables=test.transport_test_tab:part_2010 transportable=always directory=data_pump_dir dumpfile=part_2010.dmp Processing object type TABLE_EXPORT/TABLE/PLUGTS_BLK Processing object type TABLE_EXPORT/TABLE/TABLE Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS Processing object type TABLE_EXPORT/TABLE/END_PLUGTS_BLK Master table "SYSTEM"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded ***************************************************************************** * Dump file set for SYSTEM.SYS_EXPORT_TABLE_01 is: /u01/app11g/backup/part_2010.dmp ***************************************************************************** * Datafiles required for transportable tablespace TRANSPORT_TEST_TS_1: /u01/app11g/oracle/product/11.2.0/db_1/dbs/tt_ts1.dbf
  • 3. Anar Godjaev http://anargodjaev.wordpress.com Datafiles required for transportable tablespace USERS: /u01/app/oracle/oradata/EDUCATE/users01.dbf Job "SYSTEM"."SYS_EXPORT_TABLE_01" successfully completed at 13:36:23 Şimdi geri dönme yani backuptan geri alma testi yapacağız bunun için ilgili tabloyu ve onun ait olduğu tablespace leri drop ediyoruz. [oracle@rac1 ~]$ sqlplus '/as sysdba' SQL>DROP TABLE test.transport_test_tab; SQL>DROP TABLESPACE transport_test_ts_1 INCLUDING CONTENTS; SQL>DROP TABLESPACE transport_test_ts_2 INCLUDING CONTENTS AND DATAFILES; Dikkat edersek 1.tablespace te sadece content yani syntax bilgisini drop ettik,tablespace in datafile’ı halen mevcuttur. Şimdi artık aldığımız export backup ındaki bilgiyi import edebiliriz. [oracle@rac1 ~]$impdp system/oracle partition_options=departition dumpfile=part_2010.dmp transport_datafiles='tt_ts1.dbf' İşlemin output bilgiside aşağıdaki gibi olacaktır, $ impdp system/password partition_options=departition dumpfile=part_2007.dmp transport_datafiles='/u01/app/oracle/oradata/DB11G/tt_ts_1' Import: Release 11.2.0.1.0 - Production on Wed NOV18 13:42:38 2010 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Master table "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully loaded/unloaded Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01": system/******** partition_options=departition dumpfile=part_2010.dmp transport_datafiles=tt_ts1.dbf Processing object type TABLE_EXPORT/TABLE/PLUGTS_BLK Processing object type TABLE_EXPORT/TABLE/TABLE Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX ORA-39083: Object type INDEX failed to create with error: ORA-00942: table or view does not exist Failing sql is: CREATE UNIQUE INDEX "TEST"."TRANSPORT_TEST_PK" ON "TEST"."TRANSPORT_TEST_TAB" ("ID") PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(SEG_FILE 4 SEG_BLOCK 635 OBJNO_REUSE 85559 INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "USERS" PARALLEL 1 Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT ORA-39083: Object type CONSTRAINT failed to create with error: ORA-00942: table or view does not exist
  • 4. Anar Godjaev http://anargodjaev.wordpress.com Failing sql is: ALTER TABLE "TEST"."TRANSPORT_TEST_TAB" ADD CONSTRAINT "TRANSPORT_TEST_PK" PRIMARY KEY ("ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(SEG_FILE 4 SEG_BLOCK 635 OBJNO_REUSE 85559 INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "USERS" ENABLE Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS ORA-39112: Dependent object type INDEX_STATISTICS skipped, base object type INDEX:"TEST"."TRANSPORT_TEST_PK" creation failed Processing object type TABLE_EXPORT/TABLE/END_PLUGTS_BLK Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" completed with 3 error(s) at 13:42:50 Tablo segmenti tablo ismi ve partition isimlerinin kombinasyonu ile isimlendirilmiştir, bu yüzden buna bağlı olan objeler hata vermiştir çünkü yanlış tablo ismini aramaktadırlar.O yüzden verilen hataları görmezden geliyoruz. Şimdi artık oluşan yeni segmenti aşağıda görebiliriz. [oracle@rac1 ~]$ sqlplus '/as sysdba' SQL>CONN test/test SQL>EXEC DBMS_STATS.gather_schema_stats(USER); SQL>COLUMN table_name FORMAT A30 SQL>COLUMN tablespace_name FORMAT A20 SQL> set linesize 1000 SQL>SELECT table_name, tablespace_name, partitioned, num_rows FROM user_tables Where tablespace_name like '%TRANSPORT_TEST_TS_1%'; TABLE_NAME TABLESPACE_NAME PAR NUM_ROWS ------------------------------ -------------------- --- ---------TRANSPORT_TES_PART_2007 TRANSPORT_TEST_TS_1 NO 2 1 row selected.

×