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. redhat7学习笔记之从零到部署javaweb项目

    REDHAT7学习笔记 1. 安装vmware10 安装过程略,下载地址:链接: https://pan.baidu.com/s/16odKKkRYBxGWDVo1cz_wxA 注意,10以上版本不在 ...

  2. BZOJ4820 Sdoi2017 硬币游戏 【概率期望】【高斯消元】【KMP】*

    BZOJ4820 Sdoi2017 硬币游戏 Description 周末同学们非常无聊,有人提议,咱们扔硬币玩吧,谁扔的硬币正面次数多谁胜利.大家纷纷觉得这个游戏非常符合同学们的特色,但只是扔硬币实 ...

  3. 【Codeforces】Round #488 (Div. 2) 总结

    [Codeforces]Round #488 (Div. 2) 总结 比较僵硬的一场,还是手速不够,但是作为正式成为竞赛生的第一场比赛还是比较圆满的,起码没有FST,A掉ABCD,总排82,怒涨rat ...

  4. MySQL5.7中使用JSON

    一.创建表 CREATE TABLE `user` ( `uid` int(11) NOT NULL AUTO_INCREMENT, `info` json DEFAULT NULL, #注意desc ...

  5. 在后台new出页面(组件)

    Page p = new Page();            Control u = p.LoadControl("~/folderName/controlName.ascx") ...

  6. vim中的加密文件

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/sxhelijian/article/details/32911665 用vim编辑程序. 要连续输入 ...

  7. HDU 1264 Counting Squares (线段树-扫描线-矩形面积并)

    版权声明:欢迎关注我的博客.本文为博主[炒饭君]原创文章,未经博主同意不得转载 https://blog.csdn.net/a1061747415/article/details/25471349 P ...

  8. pheanstalk put 延时队列

    用pheanstalk客户端投放延时任务时,按照文档的参数顺序投放起不到延时的效果,取出(预订)job时data获取的数据也不是投放的字段值, put <pri> <delay> ...

  9. Cmake编译opencv下载不了ffmpeg时的解决办法

  10. 本地oracle的配置连接

    oraclediver_name=oracle.jdbc.driver.OracleDriverurl=jdbc:oracle:thin:@205.168.1.125:1521:orclusernam ...