Oracle 数据库 expdp 和 impdp用法

阅读更多
--查看directory库对象
select * from dba_directories;
/*
SYS  DUMP_TEST  E:\dump
SYS  QUEST_SOO_UDUMP_DIR  /home/oracle/app/oracle/diag/rdbms/bpm/bpm/trace/
SYS  QUEST_SOO_CDUMP_DIR  /home/oracle/app/oracle/diag/rdbms/bpm/bpm/cdump/
SYS  QUEST_SOO_BDUMP_DIR  /home/oracle/app/oracle/diag/rdbms/bpm/bpm/trace/
SYS  QUEST_SOO_ADUMP_DIR  /home/oracle/app/oracle/admin/bpm/adump/
SYS  XMLDIR  /ade/b/2125410156/oracle/rdbms/xml
SYS  DIR_LIKM  E:\dir_likm
SYS  DATA_PUMP_DIR  /home/oracle/app/oracle/admin/bpm/dpdump/
SYS  ORACLE_OCM_CONFIG_DIR  /home/oracle/app/oracle/product/11.2.0/dbhome_1/ccr/state
*/
--创建dump目录
create or replace directory mydump as 'E:\oracle\dump';
--给用户赋予导入、导出权限
grant read,write on directory DATA_PUMP_DIR to bpm3_in;
--导出命令
expdp bpm3_in/bpm@bpm schemas=bpm3q_testin dumpfile=bpm3q_testin.dmp DIRECTORY=DATA_PUMP_DIR  
expdp bpm3_in/bpm@bpm schemas=bpm3q_testout dumpfile=bpm3q_testout.dmp DIRECTORY=DATA_PUMP_DIR


--导入命令
--同用户名导入
impdp impdp/bpm DIRECTORY=DATA_PUMP_DIR DUMPFILE=bpm_2round_in.dmp SCHEMAS=bpm_2round_in
impdp impdp/bpm DIRECTORY=DATA_PUMP_DIR DUMPFILE=bpm_2round_out.dmp SCHEMAS=bpm_2round_out

--不同用户名导入
impdp bpm3_in/bpm@bpm DIRECTORY=DATA_PUMP_DIR DUMPFILE=bpm3q_testin.dmp remap_schema=bpm3q_testin:bpm_yanshi_in
impdp bpm3_in/bpm@bpm DIRECTORY=DATA_PUMP_DIR DUMPFILE=bpm3q_testout.dmp remap_schema=bpm3q_testout:bpm_yanshi_out

--高版本 向 低版本导入 要加版本号 
select * from v$version; --查询版本号,查询结果:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
"CORE	10.2.0.3.0	Production"
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production

例:expdp test1/fdsafdsa@orcl schemas=tcsdev1 dumpfile=tcs_20181127_10.dmp DIRECTORY=DATA_PUMP_DIR version=10.2.0.3.0

-- 导入时指定表空间
impdp test1/fdsafdsa@orcl DIRECTORY=DATA_PUMP_DIR DUMPFILE=tcs_20190305.dmp remap_schema=tcs:tcsdev1 remap_tablespace=tcs:users

-- 创建表空间语法
create temporary tablespace tcs_temp
tempfile 'E:\oracle\tabespace\tcs_temp.dbf'
size 50m
autoextend on
next 50m maxsize 20480m
extent management local;
-- 创建数据表空间的例子如下:
create tablespace tcs_data
logging
datafile 'E:\oracle\tabespace\tcs_data.dbf'
size 50m
autoextend on
next 50m maxsize 20480m
extent management local;



------------------ 用法例子-----------
impdp test1/fdsafdsa@orcl DIRECTORY=DATA_PUMP_DIR DUMPFILE=tcs_20181127.dmp remap_schema=tcs:tcsdev1
impdp test1/fdsafdsa@orcl DIRECTORY=DATA_PUMP_DIR DUMPFILE=tcs_20190305.dmp remap_schema=tcs:tcsdev1 remap_tablespace=tcs:users

select * from v$version; --查询版本号
expdp test1/fdsafdsa@orcl schemas=tcsdev1 dumpfile=tcs_20190305_10.dmp DIRECTORY=DATA_PUMP_DIR version=10.2.0.3.0

select * from dba_directories;
-- 50服务器 MYDUMP	E:\oracle\dump

impdp test/[email protected]:1521/ace DIRECTORY=MYDUMP DUMPFILE=TCS_20190305_10.DMP SCHEMAS=tcsdev1 remap_tablespace=users:tcs_data

impdp test1/fdsafdsa@orcl DIRECTORY=DATA_PUMP_DIR DUMPFILE=tcs_20190305_10.dmp remap_schema=tcsdev1:tcs

impdp sys/[email protected]:1521/cssca.com DIRECTORY=DATA_PUMP_DIR DUMPFILE=tcs_20190305.dmp remap_schema=tcs:tcsdev1


expdp sb/[email protected]:1521/ace DIRECTORY=MYDUMP DUMPFILE=SB.DUMP SCHEMAS=SB
impdp sys/[email protected]:1521/cssca.com DIRECTORY=DATA_PUMP_DIR DUMPFILE=SB.DUMP remap_tablespace=DEPLOY_TEST_SB:users

create user tcsdev1 identified by tcsdev1;

grant connect, resource,dba to tcsdev1;

impdp sys/[email protected] DIRECTORY=DATA_PUMP_DIR DUMPFILE=tcs_20190305.dmp remap_schema=tcs:tcsdev1 remap_tablespace=tcs:users;



[root@localhost ~]# su - oracle
[oracle@localhost ~]$ sqlplus / as sysdba
SQL> show user
USER is "SYS"
SQL> alter user sys identified by "oracle";
User altered.
SQL> alter user system identified by "oracle";
User altered.
SQL> exit
[oracle@localhost ~]$ sqlplus system/oracle
SQL> show user
USER is "SYSTEM"
SQL> exit
[oracle@localhost ~]$ sqlplus system/oracle
SQL> show user
USER is "SYSTEM"

expdp tcsdev1/tcsdev1@localhost:1521/TCSDEV1 schemas=tcsdev1 dumpfile=tcs_poc20190530_ver10.dmp DIRECTORY=DATA_PUMP_DIR version=10.2.0.3.0



 

你可能感兴趣的:(oracle,sql)