设为首页 收藏本站
查看: 1088|回复: 0

[经验分享] exp/imp表空间传输

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-7-6 08:49:51 | 显示全部楼层 |阅读模式
生产中为了方便数据库迁移,oracle提供了表空间传输的方式传输数据库,现在测试通过工具exp、imp迁移表空间

建立表空间及实验数据,完成后设置表空间为read only 模式
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
SQL> col file_name for a50   
SQL>  select file_id,file_name,tablespace_name from dba_data_files;
   FILE_ID FILE_NAME                                          TABLESPACE_NAME
---------- -------------------------------------------------- ------------------------------
         4 /u01/app/oracle/oradata/prod/users01.dbf           USERS
         3 /u01/app/oracle/oradata/prod/undotbs01.dbf         UNDOTBS1
         2 /u01/app/oracle/oradata/prod/sysaux01.dbf          SYSAUX
         1 /u01/app/oracle/oradata/prod/system01.dbf          SYSTEM
         5 /u01/app/oracle/oradata/test01_new.dbf             TEST
         6 /u01/app/oracle/oradata/prod/test02.dbf            TEST
         7 /u01/app/oracle/oradata/prod/test1.dbf             TEST1

7 rows selected.



SQL> create tablespace exptest datafile '/u01/app/oracle/oradata/prod/exptest01.dbf' size 100m;  

Tablespace created.

SQL> conn scott/oracle
Connected.

SQL> create table t01 (id int) tablespace exptest;

Table created.

SQL> insert into t01 values (1);  

1 row created.

SQL>  insert into t01 values (2);

1 row created.

SQL> insert into t01 values (3);   

1 row created.

SQL> commit;

Commit complete.                                                                                                               

SQL> conn / as sysdba
Connected.

SQL> alter tablespace exptest read only;

Tablespace altered.



查看表空间是自否包含
1
2
3
4
5
6
7
SQL> exec sys.dbms_tts.transport_set_check('exptest',true);

PL/SQL procedure successfully completed.

SQL> select * from sys.transport_set_violations;

no rows selected



导出可传输表空间(必须以sysdba权限)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[oracle@ora11g tstbs]$  exp userid=\'sys/oracle as sysdba\' file=exptest.dmp log=exptest.log transport_tablespace=y tablespaces=exptest

Export: Release 11.2.0.4.0 - Production on Sat Jul 4 12:30:18 2015

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.


Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in US7ASCII character set and AL16UTF16 NCHAR character set
server uses AL32UTF8 character set (possible charset conversion)
Note: table data (rows) will not be exported
About to export transportable tablespace metadata...
For tablespace EXPTEST ...
. exporting cluster definitions
. exporting table definitions
. . exporting table                            T01
. exporting referential integrity constraints
. exporting triggers
. end transportable tablespace metadata export
Export terminated successfully without warnings.



查看要导入的目标库另外一个数据库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[oracle@ora11g tstbs]$ sqlplus sys/oracle@catdb as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sat Jul 4 12:37:50 2015

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>
SQL> select tablespace_name from dba_tablespaces;

TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
TEMP
USERS
CATALOGTBS

6 rows selected.



在目标数据库下做imp操作,导入表空间
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[oracle@ora11g tstbs]$ cp /u01/app/oracle/oradata/prod/exptest01.dbf /u01/app/oracle/oradata/catdb/
   
-------------将表空间数据文件从源数据库拷贝到目标数据库下

[oracle@ora11g tstbs]$  imp userid=\'sys/oracle@catdb as sysdba\' tablespaces=exptest     file=exptest.dmp transport_tablespace=y datafiles=/u01/app/oracle/oradata/catdb/exptest01.dbf

Import: Release 11.2.0.4.0 - Production on Sat Jul 4 12:42:30 2015

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.


Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

Export file created by EXPORT:V11.02.00 via conventional path
About to import transportable tablespace(s) metadata...
import done in US7ASCII character set and AL16UTF16 NCHAR character set
import server uses AL32UTF8 character set (possible charset conversion)
. importing SYS's objects into SYS
. importing SYS's objects into SYS
. importing SCOTT's objects into SCOTT
. . importing table                          "T01"
. importing SYS's objects into SYS
Import terminated successfully without warnings.



验证:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[oracle@ora11g tstbs]$ sqlplus sys/oracle@catdb as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sat Jul 4 12:43:05 2015

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select tablespace_name from dba_tablespaces;   

TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
TEMP
USERS
CATALOGTBS
EXPTEST

7 rows selected.

SQL> select * from scott.t01;



设置表空间为read write

1
2
3
SQL> alter tablespace test read write;                                                                                          

Tablespace altered.




完成传输表空间


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-83600-1-1.html 上篇帖子: oracle排序操作 下篇帖子: 关于使用DBLINK导致EXP命令出错:EXP-00106: 数据库链接口令无效 空间
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表