Sunday, November 15, 2009
IMPORT ZIP DUMP WITHOUT UNZIP
Script to import zip dump
Here I'm creating script on o/s level
$ vi imp_compress_dump.sh
#/bin/bash
# Example Script to Import an Object from a Compressed Export File
# without compressing it, by using FIFO (named_pipes)
# Use when uncompressing an export is not possible
# due to space and/or time constraints
# Declare the name of the named pipe
NAMED_PIPE=mypipe.pipe;
# Make the named pipe (FIFO)
mknod $NAMED_PIPE p;
# Use zcat to read compressed file and direct the standard out to the named pipe created earlier
zcat expfull_test_16-nov-09_test_export.dmp.gz > $NAMED_PIPE &
# A sample imp using the named pipe
imp file=$NAMED_PIPE userid=test/test commit=y compile=n buffer=2000000000;
# Remove the named pipe
rm $NAMED_PIPE;
# Exit the script
exit;
:wq (save and exit)
--------example------------
$ sqlplus "/ as sysdba"
SQL> create user test identified by test;
User created.
SQL> grant connect, dba to test;
Grant succeeded.
SQL> connect test/test
Connected.
SQL> create table test_export (id number not null);
Table created.
SQL> insert into test_export values (1);
1 row created.
SQL> commit;
Commit complete.
SQL> ! exp userid=test/test file=expfull_test_16-nov-09_test_export.dmp log=exfutest_16-nov-09.log buffer=2000000000 statistics=none
About to export specified tables via Conventional Path ...
. . exporting table TEST_EXPORT 1 rows
exported
Export terminated successfully without warnings.
SQL> ! gzip expfull_test_16-nov-09_test_export.dmp
SQL> ! ls -ltr *.gz
-rw-r--r-- 1 oracle oinstall 459 Nov 16 09:22 expfull_test_16-nov-09_test_export.dmp.gz
SQL> exit
$ ./imp_compress_dump.sh
Export file created by EXPORT:V09.02.00 via conventional path
import done in US7ASCII character set and AL16UTF16 NCHAR character set
import server uses AL32UTF8 character set (possible charset conversion)
. importing TEST's objects into TEST
. . importing table "TEST_EXPORT" 1 rows
imported
Import terminated successfully without warnings.
$ sqlplus test/test
SQL> select * from test_export;
ID
----------
1
Subscribe to:
Post Comments (Atom)
thanks for the knowledge, very helpful post :)
ReplyDelete