Oracle11gR2导入导出实战之使用Datapump进行表空间传输

表空间检查

[oracle@localhost database]$ ps -ef|grep smon
oracle 8981 1 0 11:52 ? 00:00:01 ora_smon_orcl
oracle 10794 1 0 16:24 ? 00:00:00 ora_smon_orcl2
oracle 10836 10391 0 16:25 pts/0 00:00:00 grep smon
[oracle@localhost database]$
[oracle@localhost database]$ export ORACLE_SID=orcl
[oracle@localhost database]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Tue Apr 3 16:28:57 2018 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 file_name from dba_data_files; FILE_NAME
--------------------------------------------------------------------------------
/home/oracle/app/oradata/orcl/users01.dbf
/home/oracle/app/oradata/orcl/undotbs01.dbf
/home/oracle/app/oradata/orcl/sysaux01.dbf
/home/oracle/app/oradata/orcl/system01.dbf SQL> create tablespace test_new datafile '/home/oracle/app/oradata/orcl/test_new01.dbf' size 20m; SQL> create user test_tts identified by oracle default tablespace test_new; User created. SQL> grant connect ,resource to test_tts; Grant succeeded. SQL> conn test_tts/oracle;
Connected.
SQL>
SQL> create table test_tts as select * from all_objects where rownum <5000; Table created. SQL> create table test_tts2 as select * from all_objects where rownum < 10000; Table created. SQL> create table test_tts3(id number ,name varchar2(30)); Table created. SQL> alter table test_tts3 modify(id primary key); Table altered. SQL> insert into test_tts3 select object_id,object_name from all_objects where rownum <20; 19 rows created. SQL> col table_name format a30;
SQL> select * from cat; TABLE_NAME TABLE_TYPE
------------------------------ -----------
TEST_TTS TABLE
TEST_TTS2 TABLE
TEST_TTS3 TABLE SQL> conn / as sysdba
Connected.
SQL>
SQL> exec dbms_tts.transport_set_check('TEST_NEW',TRUE); PL/SQL procedure successfully completed. SQL> SELECT * FROM transport_set_violations; no rows selected

设置exp客户端字符集,否则会导致字符集转换造成imp失败

[oracle@localhost ~]$ export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"

exp出表空间字典表

[oracle@localhost ~]$  exp \'sys/oracle as sysdba\' file=test_new.dmp transport_tablespace= y tablespaces=test_new log=test_new_tts.log

Export: Release 11.2.0.4.0 - Production on  16:42:31 2018

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 ZHS16GBK character set and AL16UTF16 NCHAR character set
Note: table data (rows) will not be exported
About to export transportable tablespace metadata...
For tablespace TEST_NEW ...
. exporting cluster definitions
. exporting table definitions
. . exporting table TEST_TTS
. . exporting table TEST_TTS2
. . exporting table TEST_TTS3
. exporting referential integrity constraints
. exporting triggers
. end transportable tablespace metadata export
Export terminated successfully without warnings.

拷贝表空间文件

[oracle@localhost ~]$ export ORACLE_SID=orcl2

SQL> select file_name from dba_data_files;

FILE_NAME
--------------------------------------------------------------------------------
/home/oracle/app/oradata/orcl2/users01.dbf
/home/oracle/app/oradata/orcl2/undotbs01.dbf
/home/oracle/app/oradata/orcl2/sysaux01.dbf
/home/oracle/app/oradata/orcl2/system01.dbf [oracle@localhost ~]$ cp /home/oracle/app/oradata/orcl/test_new01.dbf /home/oracle/app/oradata/orcl2/

imp导入表空间

[oracle@localhost ~]$export ORACLE_SID=orcl2

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
orcl2 SQL> create user test_tts identified by oracle; User created. SQL> grant connect ,resource to test_tts; Grant succeeded. SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost ~]$ imp \'sys/oracle as sysdba\' file=test_new.dmp transport_tablespace=y tablespaces=test_new datafiles=/home/oracle/app/oradata/orcl2/test_new01.dbf Import: Release 11.2.0.4.0 - Production on 17:07:11 2018 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 ZHS16GBK character set and AL16UTF16 NCHAR character set
. importing SYS's objects into SYS
. importing SYS's objects into SYS
. importing TEST_TTS's objects into TEST_TTS
. . importing table "TEST_TTS"
. . importing table "TEST_TTS2"
. . importing table "TEST_TTS3"
. importing SYS's objects into SYS
Import terminated successfully without warnings.

验证数据

SQL> conn test_tts/oracle
Connected.
SQL> select * from cat; TABLE_NAME TABLE_TYPE
------------------------------ -----------
TEST_TTS TABLE
TEST_TTS2 TABLE
TEST_TTS3 TABLE SQL> select count(*) from TEST_TTS3; COUNT(*)
----------
19 SQL> conn / as sysdba
Connected.
SQL> SELECT tablespace_name,status from dba_tablespaces; TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE
SYSAUX ONLINE
UNDOTBS1 ONLINE
TEMP ONLINE
USERS ONLINE
TEST_NEW READ ONLY 6 rows selected. SQL> alter tablespace TEST_NEW read write; Tablespace altered.

Oracle11gR2导入导出实战之表空间传输的更多相关文章

  1. oarcle数据库导入导出,创建表空间

    oracle导入导出(前提,本机已经安装oracle和oracle客户端)导出命令: exp username/password@192.168.1.138/ORCL file=c:\test.dmp ...

  2. Oracle11gR2导入导出实战之物化视图prebuilt

    源实例上创建表 物化视图 oracle@localhost admin]$ sqlplus system/oracle@orcl2 SQL*Plus: Release 11.2.0.4.0 Produ ...

  3. Innodb 表空间传输迁移数据

    在mysql5.5之前,mysql实例中innodb引擎表的迁移是个头疼的问题,要么使用mysqldump导出,要么使用物理备份的方法,但是在mysql5.6之后的版本中,可以使用一个新特性,方便地迁 ...

  4. Oracle表空间传输测试

    源数据库平台:window 7 64bit Oracle 11g 64bit目标数据库平台:RHEL6 64bit Oracle 11g 64bit 1.查看数据集 select * from nls ...

  5. oracle imp导入库到指定表空间

    1.创建表空间 create tablespace example_tablespace datafile 'e:\****.dbf' size 10m reuse autoextend on nex ...

  6. MySQL 表空间传输

    聊到MySQL数据迁移的话题,表空间传输时一个很实用的方法. 在MySQL 5.6 Oracle引入了一个可移动表空间的特征(复制的表空间到另一个服务器)和Percona Server采用部分备份,这 ...

  7. mysql之 表空间传输

    说明:MySQL(5.6.6及以上),innodb_file_per_table开启. 1.1. 操作步骤: 0. 目标服务器创建相同表结构1. 目的服务器: ALTER TABLE t DISCAR ...

  8. mysql表空间传输(ERROR 1808) row_format设置

    文章结构如下: 从MYSQL5.6版本开始,引入了传输表空间这个功能,可以把一张表从一个数据库移到另一个数据库或者机器上.迁移的时候很方便,尤其是大表. 由于本次达到测试使用版本5.6.38传到5.7 ...

  9. 关于ORALCE一个表空间的数据导入到另一个表空间的方法(原创)

    用户:   whnaproject     所属表空间: whnaproject 新用户   : wniec            所属新表空间: wniec 要求:将用户whnaproject中的数 ...

随机推荐

  1. stm32寄存器版学习笔记02 串口通信

    stm32F103RCT6提供5路串口.串口的使用,只要开启串口时钟,设置相应的I/O口的模式,然后配置下波特率.数据位长度.奇偶校验等信息,即可使用. 1.串口的配置步骤 ①串口时钟使能 APB2外 ...

  2. android 和主线程有关的小问题

    1.在android 中 HTTP请求被不允许在主线程中执行,否则会抛出异常.如果请求时间过长,阻塞UI线程是一个非常差的体验之前,刚开始开发遇到这个问题,每次app运行到最后,发送网络请求就自己崩溃 ...

  3. 《selenium2 python 自动化测试实战》(17)——几个cookies操作

    之前我们已经学过利用cookies跳过验证码登录了,那时候我们用的方法是add_cookie()方法,这里再给大家介绍两个,一般情况下我们用不到,了解一下就可以,而且如果真的用到的时候百度也很快的: ...

  4. python 开始学习

    "人生苦短, 我用python" ---------以此敬意伟大的生产力创造!

  5. win10安装.net3.5 报错解决

    在win10光盘里提取“microsoft-windows-netfx3-ondemand-package.cab”安装包 然后放在sxs目录 新建批处理...??Cls@ECHO OFFTITLE ...

  6. CentOS(五)--Linux系统的分区概念

    一.系统分区 首先先普及一下有关系统分区的一些知识: 硬盘分区有三种,主磁盘分区.扩展磁盘分区.逻辑分区. 一个硬盘主分区至少有1个,最多4个,扩展分区可以没有,最多1个.且主分区+扩展分区总共不能超 ...

  7. jquery 操作单选按钮

    <input type="radio" name="sex" value="男" />男 <input type=&quo ...

  8. Windows 键盘快捷键概述

    在 Windows 中工作时,利用快捷键代替鼠标.可以利用键盘快捷键打开.关闭和导航“开始”菜单.桌面.菜单.对话框以及网页.键盘还可以让您更简单地与计算机交互.  单击一个标题或按 TAB 键可以突 ...

  9. 微信web端生成支付二维码

    授权获取二维码类: <?php /** * Trade类 * @author xyyphp * @date 2016/10/10 */ abstract class TradeControlle ...

  10. bzoj4764: 弹飞大爷

    Description 自从WC退役以来,大爷是越来越懒惰了.为了帮助他活动筋骨,也是受到了弹飞绵羊一题的启发,机房的小伙伴们 决定齐心合力构造一个下面这样的序列.这个序列共有N项,每项都代表了一个小 ...