Oracle DMP备份文件导入(impdp)导出(expdp)方法
一 impdp 导入
--删除用户若用户已经存在(可以使用Oracle自带的sqlplus进行连接)
SQL> drop user USER_NAME cascade
SQL> /
SQL> drop tablespace USER_TABLESPACE including contents and datafiles
SQL> /
--创建表空间 下载
SQL> CREATE TABLESPACE USER_TABLESPACE DATAFILE 'USER_tablespace.DBF' SIZE 200M AUTOEXTEND ON NEXT 50M MAXSIZE UNLIMITED PERMANENT DEFAULT STORAGE(INITIAL 64K MINEXTENTS 1 MAXEXTENTS 2147483645) MINIMUM EXTENT 64K LOGGING ONLINE
SQL> /
--创建用户
SQL> CREATE USER USER_NAME IDENTIFIED BY user_password DEFAULT TABLESPACE USER_TABLESPACE TEMPORARY TABLESPACE TEMP PROFILE DEFAULT
SQL> /
--创建用户目录
SQL> CREATE DIRECTORY directory_name as 'filePath'
SQL> /
--示例 my_dir as 'D:/db_dir' 下载
--为用户授权
SQL> GRANT CONNECT TO USER_NAME WITH ADMIN OPTION
SQL> /
SQL> GRANT DBA TO USER_NAME WITH ADMIN OPTION
SQL> /
SQL> GRANT UNLIMITED TABLESPACE TO USER_NAME WITH ADMIN OPTION
SQL> /
SQL> GRANT read, write ON DIRECTORY directory_name TO USER_NAME
SQL> /
--执行导入(退出sqlplus在CMD执行导入语句)
impdp USER_NAME/user_password@SID_NAME directory=directory_name dumpfile=USER_NAME.DMP schemas=USER_NAME logfile=USER_NAME.log;
pause;
二 expdp 导出 下载
expdp USER_NAME/user_password@SID_NAME directory=directory_name dumpfile=USER_NAME.DMP schemas=USER_NAME logfile=USER_NAME.log;
pause;