首先建立DIRECTORY对象
connect system\fjalfal@dbtest --例
CREATE DIRECTORY DUMP_dir AS ‘D:\DUMP’;
查询创建了那些子目录:
SELECT * FROM dba_directories;
需要为数据库用户授予使用DIRECTORY对象权限(用户scott)
GRANT READ, WRITE ON DIRECTORY DUMP_dir TO system;
1,导出表
Expdp system/fjalfjal@dbtest DIRECTORY=dump_dir DUMPFILE=tab.dmp TABLES=dept,emp
2,导出方案
Expdp system/fjalfjal@dbtest DIRECTORY=dump_dir DUMPFILE=schema.dmp
SCHEMAS=system,scott
3.导出表空间
Expdp system/fjalfjal@dbtest DIRECTORY=dump_dir DUMPFILE=tablespace.dmp
TABLESPACES=user01,user02
4,导出数据库
Expdp system/fjalfjal@dbtest DIRECTORY=dump_dir DUMPFILE=full.dmp FULL=Y
使用IMPDP
1, 导入表
Impdp system/fjalfjal@dbtest DIRECTORY=dump_dir DUMPFILE=tab.dmp
TABLES=dept,emp
Impdp system/fjalfjal@dbtest DIRECTORY=dump_dir DUMPFILE=tab.dmp
TABLES=scott.dept,scott.emp REMAP_SCHEMA=SCOTT:SYSTEM
第一种方法表示将DEPT和EMP表导入到SCOTT方案中,第二种方法表示将DEPT和EMP表导入的SYSTEM方案中.
注意,如果要将表导入到其他方案中,必须指定REMAP SCHEMA选项(来源:目标).
2,导入方案
Impdp system/fjalfjal@dbtest DIRECTORY=dump_dir DUMPFILE=schema.dmp
SCHEMAS=scott
Impdp system/manager DIRECTORY=dump_dir DUMPFILE=schema.dmp
SCHEMAS=scott REMAP_SCHEMA=scott:system
3,导入表空间
Impdp system/fjalfjal@dbtest DIRECTORY=dump_dir DUMPFILE=tablespace.dmp
TABLESPACES=user01
4,导入数据库
Impdp system/fjalfjal@dbtest DIRECTORY=dump_dir DUMPFILE=full.dmp FULL=y
---------------------------------------------
1.查询dba_directories查看所有directory.
SQL> select * from dba_directories;
2.使用drop directory删除这些路径.
SQL> drop directory dump_dir ;
Directory dropped
3.查询dba_directories
SQL> select * from dba_directories;
OWNER DIRECTORY_NAME DIRECTORY_PATH
4.查询dba_directories赋给哪些用户
SQL> SELECT directory_name, grantee, privilege
FROM user_tab_privs t, all_directories d
WHERE t.table_name(+)=d.directory_name;