Oracle备份恢复五(数据泵)
表空间
导出表空间
SQL> conn y/123
SQL> create tablespace test1 datafile '/home/oracle/oracle/oradata/db2/test1.dbf' size 10M;
SQL> create table test1(i number) tablespace test1;
SQL> insert into test1 values(10);
SQL> commit;
SQL> select * from test1;
I
---------------------
10 |
[oracle@oracle]# mkdir /dumpdir
SQL> create directory dumpdir as '/rman';
SQL> conn sys as sysdba
SQL> grant read,write on directory dumpdir to y;
SQL> grant dba to y;
SQL> conn y/123 |
SQL> alter tablespace test1 read only;
Tablespace altered.
SQL> exec sys.dbms_tts.transport_set_check('test1',true);
PL/SQL procedure successfully completed.
SQL> select * from sys.transport_set_violations;
no rows selected
#可见没有不满足的数据 |
SQL> ! expdp directory=dumpdir dumpfile=tbs.dmp transport_tablespaces=test1
Username: sys as sysdba
Password:
Export: Release 10.2.0.4.0 - Production on Saturday, 13 June, 2009 1:58:13
Copyright (c) 2003, 2007, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "Y"."SYS_EXPORT_TABLESPACE_01": y/******** directory=dumpdir dumpfile=ttbs.dmp tablespaces=t
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
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/COMMENT
. . exported "Y"."T" 4.906 KB 1 rows
Master table "Y"."SYS_EXPORT_TABLESPACE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for Y.SYS_EXPORT_TABLESPACE_01 is:
/dumpdir/tbs.dmp
Job "Y"."SYS_EXPORT_TABLESPACE_01" successfully completed at 01:58:42 |
2.导入表空间
#库2的IP为192.168.1.2
[oracle@oracle22]$ mkdir /dumpdir
[oracle@oracle11]$ scp /dumpdir/tbs.dmp root@192.168.1.2:/dumpdir/
[oracle@oracle11]$ scp /home/oracle/oracle/oradata/test1.dbf
root@192.168.1.2:/home/oracle/oracle/oradata/db2/ |
SQL> ! impdp directory=dumpdir dumpfile=tbs.dmp transport_datafiles='/home/oracle/oracle/oradata/db2/test1.dbf'
Username: sys as sysdba
Password:
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-31655: no data or metadata objects selected for job
Master table "SYS"."SYS_IMPORT_TABLESPACE_01" successfully loaded/unloaded
Starting "SYS"."SYS_IMPORT_TABLESPACE_01": sys/******** AS SYSDBA directory=dumpdir dumpfile=ttbs.dmp tablespaces=tt
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Job "SYS"."SYS_IMPORT_TABLESPACE_01" successfully completed at 04:53:23 |
SQL> select tablespace_name,status from dba_tablespaces where tablespace_name='TEST';
TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE
TEST1 OFFLINE |
SQL> alter tablespace test1 online;
SQL> alter tablespace test1 read write;
SQL> select * from test1;
I
-----------------------
10 |
其它导入导出
1.导出
expdp directory=dumpdir dumpfile=full.dmp full=y
expdp directory=dumpdir dumpfile=tbs.dmp tablespaces=test1,test2
expdp directory=dumpdir dumpfile=table.dmp tables=test1,test2
expdp directory=dumpdir dumpfile=schma.dmp schemas=test1,test2 |
2.导入
impdp directory=dumpdir dumpfile=full.dmp full=y
impdp directory=dumpdir dumpfile=tbs.dmp transport_datafiles='/home/oracle/oralce/oradata/db2/test1.dbf', '/home/oracle/oralce/oradata/db2/test2.dbf'
impdp directory=dumpdir dumpfile=table.dmp tables=test1,test2
impdp directory=dumpdir dumpfile=schma.dump schemas=test1,test2 |