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. 每天一个linux命令:【转载】mv命令

    mv命令是move的缩写,可以用来移动文件或者将文件改名(move (rename) files),是Linux系统下常用的命令,经常用来备份文件或者目录. 1.命令格式: mv [选项] 源文件或目 ...

  2. 关于Mybatis将查询结果中添加常量列并返回

    引言 在使用mybatis的时候,查询一个集合返回给前台页面,在有的时候,我们会添加一个常量字段到对象或者集合中,来标识这个对象属于的类型等等情况,当前台进行再次请求的时候携带此变量进行请求. 但是: ...

  3. Distributed Denial of Service

    Distributed Denial of Service https://www.cnblogs.com/163yun/p/10030890.html 全称Distributed Denial of ...

  4. 算法导论进度帖startedby20131029

    2013.10.29 今天开始啃难啃的算法导论,俗一点说,光阴似箭,剩下的时间已经不多了,所以开始好好奋进吧~ 第一章翻过去了,对附录中的数学基础再补看一遍,发现很多东西其实掌握的都很薄弱的,附录A的 ...

  5. lydsy个人代码.zip

    /s/12vaj9vUNLMlEPxlhw4xRwA ryap 感谢@yirannn 省选前++rp

  6. LG1155 双栈排序

    题意 Tom最近在研究一个有趣的排序问题.如图所示,通过2个栈\(S_1\)和\(S_2\),Tom希望借助以下4种操作实现将输入序列升序排序. 操作a 如果输入序列不为空,将第一个元素压入栈\(S_ ...

  7. spring深入内容

    https://www.ibm.com/developerworks/cn/java/j-lo-spring-principle/index.html

  8. PostgreSQL编译安装

    PostgreSQL编译安装 安装语言包 ### PostgreSQL 初始化过程中,会读取操作系统字符编码, ### 若程序需要使用zh_CN.utf-8字符编码,需要在PostgreSQL 初始化 ...

  9. Oracle条件分支查询

    Oracle的条件分支查询其实跟java的条件分支语法没啥太大的区别,只不过java多了一个switch关键字而已.看例子: SQL ELSE SUM(t1.TOTALTICKET) END tota ...

  10. Vim下的Web开发之html,CSS,javascript插件

    Vim下的Web开发之html,CSS,javascript插件   HTML 下载HTML.zip 解压HTML.zip,然后将里面的所有文件copy到C:\Program Files\Vim\vi ...