16 August 2006

Oracle Export Import Utilities

Oracle has powerful utilities such as export and import for transferring data between different hardware/software platfroms. In $ORACLE_HOME/BIN directory exp and imp utilities are used for this fashion.
Oracle içinde verilerin başka platformlara taşınması için export ve import kullanılmaktadır. Bu sayede veriler gerek yazılım gerek donanım açısından farklı sistemler arasında taşınabilmektedir. ORACLE_HOME dizini içindeki BIN dizinde exp ve imp adlı programcıklar bu işlemler için kullanılmaktadır.


Transfer operation has done via files which called dump. Dump files are created with exp and can be loaded via emp utilities. The important thing is that transferring of dump files must be done via binary mode ftp. Otherwise dump file can be corrupted. For ASCII files you are able to use SQL*Loader utility.
Taşınma işlemi binary formatında dump adı verilen dosyalar ile yapılmaktadır. Bu dosyalar exp ile oluşturulup imp ile istenen yere yüklenebilecek şekildedir. Oluşturulan dump dosyası ftp aracılığı ile taşınıyor ise, bu taşımayı binary ftp modu ile yapmak gerekmektedir. Aksi takdirde dosyanın bozulmasına neden olunabilinir. Buna dikkat edilmelidir. ASCII formatında taşıma için SQL*Loader kullanılmaktadır.


With export the object and all of its dependent objects are taken. You can backup your database via export/import whereas it is not recommended. For backup issues utilities such as RMAN might be used.
Export ile alacağınız nesne ile birlikte ona bağlı bütün neseneler de alınır. Java kaynak dosyalarını export ile almak mümkün değildir. Full bir export ile veritabanının bir nevi backup alınmış olsa da bu tavsiye edilen bir yol değildir. Büyük veritabanları için RMAN gibi özelleşmiş araçlar kullanılmalıdır.


You can detect any of corruption data with export.
Veritabanı içindeki verilerin okunamaması(data corruption) gibi bir durumun tespit edilebilmesi için de export kullanılabilir.


Transferring data with SCN or time with setting FLASHBACK_SCN, FLASHBACK_TIME parameters.
Export ile belirli bir SCN’e veya zamana göre de taşıma yapılabilmektedir. Bunun için gerekli parametrelerin uygun bir şekilde çağırılması gerekir.(FLASHBACK_SCN, FLASHBACK_TIME)


Not only full table, data based on condition can be exported.
Sadece belirli bir tablonun değil, tablo içinde belirli kritere bağlı kayıtların da gelmesi sağlanabilmektedir.(QUERY)

You can increase performance of export/import via defining COMMIT and ANALYZE parameters.
Export edilirken commit edilip edilmemesini veya ilgili nesnelerin analiz edilip edilmemesi belirlenebilmektedir.(COMMIT, ANALYZE) Bu kimi zaman performans arttrıcı olarak kullanılabilmektedir.


I described how to export a table from Microsoft system to Unix system below:
Aşağıda Microsoft tabanlı bir sistemden bulunan bir tablonun belirli kayıtlarının export edilip Unix tabanlı bir sisteme nasıl import edildiği belirtilmiştir.


On Windows side a table is created
Windows tarafında bir tablo oluşturulur:


create table hr.sample_emp as select * from hr.employees


Parameter file(exp_params.txt) is cretaed
Export ile kullanılacak parametre dosyası(exp_params.txt) hazırlanır.

FILE=dept50_emp.dmp
LOG=dept50_emp_exp.log
QUERY='where department_id = 50'
TABLES=hr.sample_emp
ROWS=y
COMPRESS=y

With this file
Bu dosya ile

select * from hr.sample_emp 'where department_id = 50

query result taken from hr schema and exported to dept50_emp.dmp file.
sorgusu ile gelecek kayıtları ve hr.sample_emp tablo yapısı ile birlikte dept50_emp.dmp dosyasına export edileceği belirtilmektedir.

With command prompt needed calls are done
Command prompt açılır ve gerekli çağırımlar yapılarak işlemin yapılması sağlanır:

E:\oracle\product\10.2.0\db_2\BIN>exp 'sys/orcl@ORCL as SYSDBA' PARFILE=exp_params.txt

Export: Release 10.2.0.1.0 - Production on Wed Aug 16 14:21:38 2006

Copyright (c) 1982, 2005, Oracle. All rights reserved.


Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path ...
Current user changed to HR
. . exporting table SAMPLE_EMP 45 rows exported
Export terminated successfully without warnings.

E:\oracle\product\10.2.0\db_2\BIN>


exp 'sys/orcl@ORCL as SYSDBA' PARFILE=exp_params.txt

line does export operation
satırı export işlemini yapmaktadır.


dept50_emp_exp.log and dept50_emp.dmp files are created via this command.
Bu komut ile dept50_emp_exp.log ve dept50_emp.dmp adlı dosyalar oluşmaktadır.


For import, dept50_emp.dmp file is transferred via binary mode ftp.
Import için dept50_emp.dmp dosyası Unix ortamına binary modda ftp ile atılır.


Parameter file(imp_params.txt) is created for import.
İmport işlemi için kullanılacak parametre dosyası(imp_params.txt) hazırlanır.


FILE=dept50_emp.dmp
SHOW=n
IGNORE=n
GRANTS=y
FROMUSER=hr
TOUSER=sys
TABLES=sample_emp
ANALYZE=n
LOG=dept50_emp_imp.log

Via this file, sample_emp table from hr schema imported to sys schema.
Bu dosya ile hr şemasından alınan sample_emp adlı tablonun sys şeması altına alınacağı belirtilmiştir.

On Unix environment needed sheel calls are done
Unix ortamından açılan bir shell ile gerekli komutllar çağırılır:

oracle@zerg_shp01> imp \'sys/general@general as sysdba\' PARFILE=imp_params.txt

Import: Release 10.1.0.2.0 - Production on Wed Aug 16 14:16:43 2006

Copyright (c) 1982, 2004, Oracle. All rights reserved.


Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options

Export file created by EXPORT:V10.02.01 via conventional path
import done in WE8ISO8859P9 character set and AL16UTF16 NCHAR character set
import server uses WE8ISO8859P1 character set (possible charset conversion)
export client uses WE8MSWIN1252 character set (possible charset conversion)
IMP-00008: unrecognized statement in the export file:
. . importing table "SAMPLE_EMP" 45 rows imported
Import terminated successfully with warnings.
oracle@zerg_shp01>


imp \'sys/sys@general as sysdba\' PARFILE=imp_params.txt


import has been done via this command
komutu ile import işlemi yapılmıştır.


With a query you can check the process.
Veritabanından bir sorgu ile işlemin doğru yapılıp yapılmadığı kontrol edilebilir:


select * from sys.sample_emp





For more information please visit
http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14215/exp_imp.htm 

No comments: