Use the ability to transmit tablespaces to copy data

Source: Internet
Author: User

Restrictions on table space that can be transferred: The table space technology cannot be applied to system tablespaces or objects owned by sys users. In the transmission tablespace, The tablespace must be self-contained. The self-contained table space indicates that the internal tablespace set used for transmission does not reference the external tablespace set.

Portable tablespace lab environment
  OS IP SID Storage Method Tablespace User Table
Source database RedHat5.4 10.10.10.8 Orcl File System Tb1, tb2 U1, u2

T1, t2

Target Database Redhat5.4 10.10.10.7 Orcl ASM -- U1, u2 --

Note: In the source database, user u1 uses the tb1 tablespace, which contains a table t1. Use exp/imp for transmission. On the source database, user u2 uses the tb2 tablespace, which contains a table t2. Use expdp/impdp for transmission.

The following is a script for creating a test environment (operations performed on the source database)

  1. USERIs"SYS"
  2. SQL>CreateTablespace tb1 datafile'/U01/app/Oracle/oradata/orcl/tb1.dbf' Size10 m;
  3. The tablespace has been created.
  4. SQL>CreateTablespace tb2 datafile'/U01/app/oracle/oradata/orcl/tb2.dbf' Size10 m;
  5. The tablespace has been created.
  6. SQL>Create UserU1 identifiedByU1DefaultTablespace tb1;
  7. The user has been created.
  8. SQL>Create UserU2 identifiedByU2DefaultTablespace tb2;
  9. The user has been created.
  10. SQL>Grant Connect, ResourceToU1, u2;
  11. Authorization successful.
  12. SQL>Create TableU1.t1As Select*FromDba_objectsWhereRownum: <100;
  13. The table has been created.
  14. SQL>Create TableU2.t2As Select*FromDba_objectsWhereRownum: <200;
  15. The table has been created.
  16. SQL>Select Count(*)FromU1.t1;
  17. COUNT(*)
  18. ----------
  19. 99
  20. SQL>Select Count(*)FromU2.t2;
  21. COUNT(*)
  22. ----------
  23. 199

Practice of table space Transfer

1. Check whether the platform for the tablespace to be transmitted is compatible (both the source database and the target database are the same, because they are all redhat5.4 operating systems)

  1. SQL>SelectTp .*FromV $ transportable_platform tp, v $DatabaseDWhereTp. PLATFORM_NAME = d. PLATFORM_NAME;
  2. PLATFORM_ID PLATFORM_NAME ENDIAN_FORMAT
  3. ------------------------------------------------------------
  4. 10 Linux IA (32-Bit) Little

2. Check whether the transmitted tablespace is self-contained (operations performed on the source database)

  1. SQL> showUser
  2. USERIs"SYS"
  3. SQL>ExecDbms_tts.transport_set_check ('Tb1',True);-- Only check Constraints
  4. The PL/SQL process is successfully completed.
  5. SQL>ExecDbms_tts.transport_set_check ('Tb2',True);-- Only check Constraints
  6. The PL/SQL process is successfully completed.
  7. SQL>ExecDbms_tts.transport_set_check ('Tb1',True,True);-- Strict check
  8. The PL/SQL process is successfully completed.
  9. SQL>ExecDbms_tts.transport_set_check ('Tb2',True,True);-- Strict check
  10. The PL/SQL process is successfully completed.
  11. SQL>Select*FromTransport_set_violations;-- A record does not meet the requirements
  12. Unselected row

Note: The strict method is not only to check whether the objects referenced by the spatial set (such as tables) are self-contained, but also to check the objects referenced by other tablespaces (such as indexes ), whether the referenced table is in the tablespace set. If the tablespace to be transmitted is not self-contained, multiple tablespaces can be transmitted together.

3. Set the tablespace to be transferred as read-only (operations performed on the source database)

  1. SQL> showUser
  2. USERIs"SYS"
  3. SQL>AlterTablespace tb1Read Only;
  4. The tablespace has been changed.
  5. SQL>AlterTablespace tb2Read Only;
  6. The tablespace has been changed.

4. Export table space set metadata (operations performed on the source database)

  1. SQL> showUser
  2. USERIs"SYS"
  3. SQL>Select*FromDba_directoriesWhereDIRECTORY_NAME ='Exp';
  4. OWNER DIRECTORY_NAME DIRECTORY_PATH
  5. --------------------------------------------------------------------------------------------------------------
  6. Sys exp/u01/exp
  7. SQL>!
  8. [Oracle @ linux ~] $ Cd/u01/exp/
  9. [Oracle @ linux exp] $ ll
  10. Total 0
  11. [Oracle @ linux exp] $ exp \"Sys/oracle @ orcl as sysdba \"Tablespaces = tb1 transport_tablespace = y file = tb1.dmp
  12. [Oracle @ linux exp] $ expdp system/oracle @ orcl directory = exp dumpfile = tb2.dmp transport_tablespaces = tb2 nologfile = y
  13. [Oracle @ linux exp] $ ll
  14. Total 96
  15. -Rw-r-- R -- 1 oracle oinstall 16384 10-06 tb1.dmp
  16. -Rw-r----- 1 oracle oinstall 77824 10-06 tb2.dmp

5. Convert the byte sequence. If the byte sequence of the two platforms is different, you need a conversion process in the middle. You can use rman. (Optional, not executed here .)

  1. RMAN>ConvertTablespace booksToPlatform'Microsoft Windows IA (32-bit )'Format'/Tmp/% N _ % F';
  2. RMAN>ConvertDatafile'/Tmp/BOOKS_5'Db_file_name_convert'/Tmp/BOOKS_5','/Tmp/books01.dbf';

Note: This is the purpose of the first check, although conversion is not required here. Only the conversion method is provided here.

6. Copy metadata and data files to the target database (operations performed on the target database)

  1. [Root @ linux u01] # chown-R oracle: oinstall tb/
  2. [Root @ linux u01] # cd tb/
  3. [Root @ linux tb] # ll
  4. Total 20624
  5. -Rw-r-- R -- 1 oracle oinstall 10493952 10-07 tb1.dbf
  6. -Rw-r-- R -- 1 oracle oinstall 16384 10-07 tb1.dmp
  7. -Rw-r-- R -- 1 oracle oinstall 10493952 10-07 tb2.dbf
  8. -Rw-r-- R -- 1 oracle oinstall 77824 10-07 tb2.dmp
  9. [Root @ linux tb] # pwd
  10. /U01/tb

7. Modify the tablespace of the source database to read/write (the operations performed on the source database)

  1. SQL> showUser
  2. USERIs"SYS"
  3. SQL>AlterTablespace tb1ReadWrite;
  4. The tablespace has been changed.
  5. SQL>AlterTablespace tb2ReadWrite;
  6. The tablespace has been changed.

8. Check whether the size of the source tablespace is the same as that of the target database.

Source database

  1. SQL>SelectBlock_sizeFromDba_tablespacesWhereTablespace_name ='Tb1';
  2. BLOCK_SIZE
  3. ----------
  4. 8192
  5. SQL>SelectBlock_sizeFromDba_tablespacesWhereTablespace_name ='Tb2';
  6. BLOCK_SIZE
  7. ----------
  8. 8192
  9. SQL> show parameter db_block_size
  10. NAMETYPE VALUE
  11. -----------------------------------------------------------------------------
  12. Db_block_sizeInteger8192

Target Database

  1. SQL> show parameter db_block_size
  2. NAMETYPE VALUE
  3. -----------------------------------------------------------------------------
  4. Db_block_sizeInteger8192
  • 1
  • 2
  • Next Page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.