首页 > 其他 > 详细

数据泵备份

时间:2021-04-26 11:01:53      阅读:14      评论:0      收藏:0      [点我收藏+]

1.expdp/impdp

c:\> sqlplus /nolog
SQL> conn sys/root123 as sysdba

使用EXPDP命令导出数据(可以按照表导出,按照用户模式导出,按照表空间导出和全库导出),使用IMPDP命令导入数据(可以按照表导入,按照用户模式导入,按照表空间导出和全库导入)。

1.1expdp备份

1.1.1导出表

导出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

 

1.1.2导入指定表

导入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

  

1.1.3用户表导入到指定用户

scott用户下的emp表导入到tom用户下

C:\Users\Administrator> impdp system/root123 directory=dump_dir dumpfile=scotttab.dmp tables=scott.emp,scott.dept REMAP_SCHEMA=SCOTT:TOM

  

1.3.1导出表空间

创建表空间,在表空间上创建一个表,并为表插入记录

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!