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. 如何在CentOS系统中安装配置SNMP服务

    CentOS(Community Enterprise Operating System,中文意思是:社区企业操作系统)是Linux发行版之一,现在有一大部分服务器在使用此操作系统:SNMP(简单网络 ...

  2. 如何使用 nslookup 查域名的 ttl

    如何使用 nslookup 查域名的 ttl nslookup 经常用,但是最近才使用到查 ttl 的信息. 域名的 ttl 也是网站优化的一个重要参数. nslookup -d www.fastad ...

  3. 8.Python编写登录接口

    1.python需安装flask,在命令行窗口输入:pip3 install flask 2.代码如下所示: from flask import Flask,request,jsonify,sessi ...

  4. 从汇编的角度看待变量类型与sizeof的机制

    1.动机:前段时间,一直有个疑问,就是编译器是从哪里知道数据的类型的,数据的类型是存在内存里面的么,因为自己调试编译器,发现内存中并没有多余的数据,后来在群上发问,才知道数据在编译成汇编的过程就知道数 ...

  5. 常见企业IT支撑【2、samba共享文件夹】

    samba共享文件夹,较Window自带的比较:开源,安全 建议安装samba4,兼容性好 1.安装samba #yum -y install samba4 samba4-client 2.备份sam ...

  6. rapidjson的read和write的sample

    头文件 #include "json/document.h" #include "json/prettywriter.h" #include "jso ...

  7. MySQL COUNT(*) & COUNT(1) & COUNT(col) 比较分析

    在面试的时候我们会经常遇到这个问题: MySQL 中,COUNT(*).COUNT(1).COUNT(col) 有区别吗? 有区别. 接下来我们分析一下这三者有什么样的区别. 一.SQL Syntax ...

  8. $.each $.map 和 $().each $().map

    $.each :用于遍历数据,如json. $(function () { var data = [{'name': 'a', 'age': 12}, {'name': 'b', 'age': 12} ...

  9. 操作系统-百科: UNIX

    ylbtech-操作系统-百科: UNIX UNIX操作系统(尤尼斯),是一个强大的多用户.多任务操作系统,支持多种处理器架构,按照操作系统的分类,属于分时操作系统,最早由KenThompson.De ...

  10. Cassandra 的启动和初始化

    Cassandra常用命令 Cassandra启动过程详解[原创] Cassandra 的入口 CassandraDaemon 作为Cassandra的入口,做了以下几件事: load configu ...