Transportable Tablespaces

FROM:http://www.idevelopment.info/data/Oracle/DBA_tips/Oracle8i_New_Features/ORA8i_17.shtml
Transportable Tablespaces
by Jeff Hunter, Sr. Database Administrator

Contents
Overview Introduction to Transportable Tablespaces Using Transportable Tablespaces

Overview Oracle's Transportable Tablespace is one of those much awaited features that was introduced in Oracle8i (8.1.5) and is commonly used in Data Warehouses (DW). Using transportable tablespaces is much faster than using other utilities like export/import, SQL*Plus copy tables, or backup and recovery options to copy data from one database to another.
This article provides a brief introduction into configuring and using transportable tablespaces.
Introduction to Transportable Tablespaces Before covering the details of how to setup and use transportable tablespaces, let's first discuss some of the terminology and limitations to provide us with an introduction.
The use of transportable tablespaces are much faster than using export/import, SQL*Plus copy tables, or backup and recovery options to copy data from one database to another.

A transportable tablespace set is defined as two components:
All of the datafiles that make up the tablespaces that will be moved.
AND

An export that contains the data dictionary information about those tablespaces.

COMPATIBLE must be set in both the source and target database to at least 8.1.

When transporting a tablespace from an OLTP system to a data warehouse using the Export/Import utility, you will most likely NOT need to transport TRIGGER and CONSTRAINT information that is associated with the tables in the tablespace you are exporting. That is, you will set the TRIGGERS and CONSTRAINTS Export utility parameters equal to "N".

The data in a data warehouse is inserted and altered under very controlled circumstances and does not require the same usage of constraints and triggers as a typical operational system does.

It is common and recommended though that you use the GRANTS option by setting it to Y.

The TRIGGERS option is new in Oracle8i for use with the export command. It is used to control whether trigger information, associated with the tables in a tablespace, are included in the tablespace transport.
Limitations of Transportable Tablespaces:
The transportable set must be self-contained.

Both the source and target database must be running Oracle 8.1 or higher release.

The two databases do not have to be on the same release

The source and target databases must be on the same type of hardware and operating-system platform.

The source and target databases must have the same database block size.

The source and target databases must have the same character set.

A tablespace with the same name must not already exist in the target database.

Materialized views, function-based indexes, scoped REFs, 8.0 compatible advanced queues with multiple-recipients, and domain indexes can't be transported in this manner. (As of Oracle8i)

Users with tables in the exported tablespace should exist in the target database prior to initiating the import. Create the user reported by the error message.
Explanation: The metadata exported from the target database does not contain enough information to create the user in the target database. The reason is that, if the metadata contained the user details, it might overwrite the privileges of an existing user in the target database.
(i.e. If the user by the same name already exists in the target database)
By not maintaining the user details, we preserve the security of the database.
Using Transportable Tablespaces In this section, we finally get to see how to use transportable tablespaces. Here is an overview of the steps we will perform in this section:
Verify that the set of source tablespaces are self-contained Generate a transportable tablespace set. Transport the tablespace set Import the tablespaces set into the target database.

In this example, we will be transporting the tablespaces, "FACT1, FACT2, and FACT_IDX" from a database named DWDB to REPORTDB. The user that owns these tables will be "DW" and password "DW".

Verify Self-Contained Status with the DBMS_TTS Package To verify that all tablespaces to transport are self-contained, we can use the TRANSPORT_SET_CHECK procedure within the DBMS_TTS PL/SQL Package. The first parameter to this procedure is a list of the tablespaces to transport. Keep in mind that all indexes for a table, partitions, and LOB column segments in the tablespace must also reside in the tablespace set. The second parameter to this procedure is a boolean value that indicates whether or not to check for referential integrity.

SQL> connect sys/change_on_install@dwdb as sysdbaSQL> exec DBMS_TTS.TRANSPORT_SET_CHECK('fact1, fact2', TRUE);SQL> SELECT * FROM TRANSPORT_SET_VIOLATIONS;VIOLATIONS--------------------------------------------------------------------------------Index DW.DEPT_PK in tablespace FACT_IDX enforces primary constriants of table DW.DEPT in tablespace FACT1Index DW.EMP_PK in tablespace FACT_IDX enforces primary constriants of table DW.EMP in tablespace FACT1
OOOPS! As we can see from the above example, I forgot to include all tablespaces that will make this self-contained. In this example, I forgot to include the FACT_IDX tablespace. Let's correct that:
SQL> exec DBMS_TTS.TRANSPORT_SET_CHECK('fact1, fact2, fact_idx', TRUE);SQL> SELECT * FROM TRANSPORT_SET_VIOLATIONS;no rows selected

Generate a Transportable Tablespace Set To generate a Transportable Tablespace Set, you will need to perform the following:
Place all tablespace within the tablespace set in READ ONLY mode. Use Export to gather tablespace data-dictionary information. Copy datafiles and the export dump from the source location to the target location. Place all tablespace within the tablespace set back to READ/WRITE.
% sqlplus "sys/change_on_install@dwdb as sysdba"SQL> ALTER TABLESPACE fact1 READ ONLY;SQL> ALTER TABLESPACE fact2 READ ONLY;SQL> ALTER TABLESPACE fact_idx READ ONLY;SQL> exit% exp userid=\"sys/change_on_install@dwdb as sysdba\" transport_tablespace=y tablespaces=fact1,fact2,fact_idx triggers=y constraints=y grants=y file=fact_dw.dmp% cp /u10/app/oradata/DWDB/fact1_01.dbf /u10/app/oradata/REPORTDB/fact1_01.dbf% cp /u10/app/oradata/DWDB/fact2_01.dbf /u10/app/oradata/REPORTDB/fact2_01.dbf% cp /u09/app/oradata/DWDB/fact_idx01.dbf /u09/app/oradata/REPORTDB/fact_idx01.dbf% sqlplus "sys/change_on_install@dwdb as sysdba"SQL> ALTER TABLESPACE fact1 READ WRITE;SQL> ALTER TABLESPACE fact2 READ WRITE;SQL> ALTER TABLESPACE fact_idx READ WRITE;SQL> exit

Transport the Tablespace Set To actually transport the tablespace, this is nothing more than copying (or FTP'ing) all tablespace set datafiles to be put in their proper location on the target database. In the section previous to this, we did that with the cp command in UNIX.
In some cases this would be necessary if the files where copied off to a staging area in the previous step.

Import the Tablespace Set Before actually importing the tablespace(s) into the target database, you will need to ensure that all users that own segments in the imported tablespaces exist. For this example, the only user that owns segments in the exported tablespaces is DW. I will create this user:
% sqlplus "sys/change_on_install@reportdb as sysdba"SQL> create user dw identified by dw default tablespace users;SQL> grant dba, resource, connect to dw;SQL> exit

We now use the Import utility to bring the tablespace set's data-dictionary information into the target database.
The two required parameters are TRANSPORT_TABLESPACE=Y and DATAFILES='...' as in the following example:
% imp userid=\"sys/change_on_install@reportdb as sysdba\" transport_tablespace=y datafiles='/u10/app/oradata/REPORTDB/fact1_01.dbf, /u10/app/oradata/REPORTDB/fact2_01.dbf, /u09/app/oradata/REPORTDB/fact_idx01.dbf' file=fact_dw.dmp

Final Cleanup When the tablespaces are successfully imported into the target database, they are in READ ONLY mode. If you intend to use the tablespaces for READ WRITE, you will need to manually alter them:
% sqlplus "sys/change_on_install@reportdb as sysdba"SQL> ALTER TABLESPACE fact1 READ WRITE;SQL> ALTER TABLESPACE fact2 READ WRITE;SQL> ALTER TABLESPACE fact_idx READ WRITE;SQL> exitPage Count: 261

时间: 2024-09-20 17:26:02

Transportable Tablespaces的相关文章

什么是网格数据库

网格计算已经成为热点,它所带来的低成本.高性能以及方便的计算资源共享正是众多企业所追求的.未来的数据库将构筑在网格计算环境之上. RAC(Real Application Cluster,真正应用集群)是Oracle9i数据库中采用的一项新技术,也是Oracle数据库支持网格计算环境的核心技术.它的出现解决了传统数据库应用中面临的一个重要问题:高性能.高可伸缩性与低价格之间的矛盾. 除了RAC技术,Oracle9i数据库还提供其他功能来支持网格计算,包括支持在数据库之间进行数据快速复制的Tran

作为一个新手的Oracle(DBA)学习笔记

Oracle数据库笔记 Jack Chaing 作者QQ595696297 交流群 127591054 祝大家学习进步. 如果大家想看Word版本的可以去下载:Word排版比较清晰一些. http://download.csdn.net/detail/jack__chiang/9810532 此笔记是作者本人去年开始从一个DBA新人的学习笔记,积累至今,希望拿出来给那些对DBA有兴趣的童孩学习,大家一起努力嘛. 此笔记记录了作者工作学习中从零基础的学习的记录,和从中遇见的问题与问题的解决!很高兴

MySQL 备份恢复单个innodb表的教程

在实际环境中,时不时需要备份恢复单个或多个表(注意:这里除非明确指定,所说的表一律指InnoDB表),而对于innodb引擎恢复单个表需要整体的恢复,xtrabackup也可以单个表恢复,只不过是用的正则过滤的,不知最新版本是否支持表空间传输特性.本文将要说说怎么移动或复制部分或全部的表到另一台服务器上,而所要用到的技术点就是transportable tablespace特性,这就意味着MySQL5.6.6以及以上版本才支持. 表空间传输特性允许表空间从一个实例移动到另一个实例上.这在以前版本

InnoDB可传输表空间

Copying File-Per-Table Tablespaces to Another Server Transportable Tablespace Examples Transportable Tablespace Internals 背景 大家先来回顾一下,如果要将innoDB中的一个表 Moving or Copying 到另外一台(machine|instance)上,如何做? MySQL Enterprise Backup (no need consider) Copying D

What's new in MySQL5.7

How MySQL5.7 new feature rocks your heart 新增特性 种类 特性名称 备注 相关链接 Performance&Scalability online rename index inplace方式,针对所有引擎 alter index Performance&Scalability online alter varchar [0~255]是inplace修改,[256 ~ 256+] 是inplace修改 online alter varchar Per

MySQL 5.7新特性

    关于MySQL5.7,现在据说也是蛮火的,此文主要参照官方文档整理的,时日有些长了,最新的特性可能没采集进来,各位看客朋友们随意就好~~勿喷 新的特性 1.安全性增强 1)mysql.user表.plugin字段要求非空:新增时间戳字段保存密码最后被修改时间:不再使用password字段,使用authentication_string替代 2)安装与服务.全新的安装方式mysqld --initialize:安装完毕后只创建一个本地root账户,即root@'localhost':无匿名

美图秀秀DBA谈MySQL运维及优化

随着MySQL应用的不断普及和自身发展,如何更好的优化MySQL和使用MySQL,依然是一个比较有挑战的问题,尤其是在业务快速增长的场景下.本次分享主要介绍一些通用的运维优化实践和问题,以及未来的一些方向.  目录 MySQL的优势和劣势 数据库规范化 Sharding拆分 数据库备份 性能优化 从每个月的db engines排名可以看到,关系数据库依然占主导地位,nosql的种类和可选择空间更大,总共283种数据库,里面大多数也是NoSQL. 如何选择数据库,从以下几个因素考虑: 应用场景:O

Oracle 跨操作系统 迁移 说明

关于跨OS 的DB 迁移,MOS 上有相关的文章说明:[ID733205.1]. To migrate anexisting Oracle database (NOT BINARIES)  from one Operating Systemplatform to another (i.e. Windows to Solaris) ,This can occur as part ofan Oracle version upgrade (Oracle 8i .. Oracle 11G) or wit

MySQL InnoDB 共享表空间和独立表空间

MySQL  InnoDB 共享表空间和独立表空间 官网:https://dev.mysql.com/doc/refman/5.6/en/innodb-multiple-tablespaces.html 前言:学习mysql的时候总是习惯性的和oracle数据库进行比较.在学习mysql InnoDB的存储结构的时候也免不了跟oracle进行比较.Oracle的数据存储有表空间.段.区.块.数据文件:mysql InnoDB的存储管理也类似,但是mysql增加了一个共享表空间和独立表空间的概念: