c:\> sqlplus /nolog SQL> conn sys/root123 as sysdba
使用EXPDP命令导出数据(可以按照表导出,按照用户模式导出,按照表空间导出和全库导出),使用IMPDP命令导入数据(可以按照表导入,按照用户模式导入,按照表空间导出和全库导入)。
导出scott用户的emp、dept表
创建一个操作目录 SQL> create directory dump_dir as ‘C:\app\Administrator\oradata\orcl\dump\test‘ 授权用户操作dump_dir目录的权限 SQL> grant read,write on directory dump_dir to scott; ? ? SQL> col directory_name for a20 SQL> col directory_path for a60 SQL> col owner for a8 SQL> select * from dba_directories;
创建测试用户tom并授权
SQL> create user tom identified by 123456; SQL> grant connect,resource to tom; SQL> grant read,write on directory dump_dir to tom;
导出scott用户下的emp和dept表
c:\> expdp scott/123456 directory=dump_dir dumpfile=scotttab.dmp tables=emp,dept
导入scott用户emp表
用户scott删除emp表
SQL> conn scott/123456 SQL> drop table emp;
导入emp表
c:\> impdp scott/123456 directory=dump_dir dumpfile=scotttab.dmp tables=emp
scott用户下的emp表导入到tom用户下
C:\Users\Administrator> impdp system/root123 directory=dump_dir dumpfile=scotttab.dmp tables=scott.emp,scott.dept REMAP_SCHEMA=SCOTT:TOM
创建表空间,在表空间上创建一个表,并为表插入记录
SQL> show user USER 为 "SYS" SQL> create tablespace xx datafile ‘c:\temp\xx.dbf‘ size 100m; ? SQL> alter user scott account unlock; SQL> conn scott/root123; SQL> create table aa(id int,name varchar2(10)) tablespace xx; SQL> insert into aa values(1,‘tom1‘); SQL> commit;
C:\Users\Administrator>expdp system/root123 directory=dump_dir dumpfile=xx.dmp tablespaces=xx
删除表空间及数据文件
SQL> show user; SQL> drop tablespace xx including contents and datafiles;
查看表
SQL> conn scott/root123 SQL> select * from tab; aa表已被删除
未完。。。
原文:https://www.cnblogs.com/BrokenEaves/p/14702706.html