Converting Data Between Platforms

本文详细介绍了如何在不同字节序的平台上使用DBMS_FILE_TRANSFER包和RMAN CONVERT命令来转换和迁移数据。在源数据库和目标数据库之间,数据块会被自动转换为目标平台的字节序。通过DBMS_FILE_TRANSFER的GET_FILE或PUT_FILE过程,以及RMAN的CONVERT命令,可以在传输过程中完成数据转换。同时提供了在源系统和目标系统上进行转换的步骤示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

When you perform a transportable operation, and the source platform and the target platform are of different endianness, you must convert the data being transported to the target format.

You can use the DBMS_FILE_TRANSFER package or the RMAN CONVERT command to convert data. To query the endian format of platform:

COLUMN PLATFORM_NAME FORMAT A40

COLUMN ENDIAN_FORMAT A14

SELECT PLATFORM_ID, PLATFORM_NAME, ENDIAN_FORMAT

  FROM V$TRANSPORTABLE_PLATFORM

  ORDER BY PLATFORM_ID;

Converting Data Between Platforms Using the DBMS_FILE_TRANSFER Package

You can use the GET_FILE or PUT_FILE procedure in the DBMS_FILE_TRANSFER package to convert data between platforms during the data file transfer.

When you use one of these procedures to move data files between the source platform and the target platform, each block in each data file is converted to the target platform's endianness. The conversion occurs on the target platform.

The example makes the following assumptions:

  1. The GET_FILE procedure will transfer the data file.
  2. The mytable.342.123456789 data file is being transferred to a different platform.
  3. The endianness of the source platform is different from the endianness of the target platform.
  4. The global name of the source database is dbsa.example.com.
  5. Both the source database and the target database use Oracle Automatic Storage Management (Oracle ASM).

Note: You can also use the DBMS_FILE_TRANSFER package to transfer data files between platforms with the same endianness.

Complete the following steps to convert the data file by transferring it with the GET_FILE procedure:

  1. Connect to the source database as an administrative user that can create directory objects.
  2. Create a directory object for the directory that contains the data file that will be transferred to the target database.

CREATE OR REPLACE DIRECTORY sales_dir_source AS '+data/dbsa/datafile';

  1. Connect to the target database as an administrative user that can create database links, create directory objects, and run the procedures in the DBMS_FILE_TRANSFER package.
  2. Create a database link from the target database to the source database.

The connected user at the source database must have read privilege on the directory object you created in Step 2.

  1. Create a directory object to store the data files that will be transferred to the target database.

The user at the local database who will run the procedure in the DBMS_FILE_TRANSFER package must have write privilege on the directory object.

CREATE OR REPLACE DIRECTORY sales_dir_target AS '+data/dbsb/datafile';

  1. Run the GET_FILE procedure in the DBMS_FILE_TRANSFER package to transfer the data file.

BEGIN

  DBMS_FILE_TRANSFER.GET_FILE(

    source_directory_object      => 'sales_dir_source',

    source_file_name             => 'mytable.342.123456789',

    source_database              => 'dbsa.example.com',

    destination_directory_object => 'sales_dir_target',

    destination_file_name        => 'mytable');

END;

/

Converting Data Between Platforms Using RMAN

RMAN的CONVERT使用详细见《Transporting Data Across Platforms by RMAN CONVERT》

Running the RMAN CONVERT command is an additional step that can be completed on the source or target platform. It converts the data being transported to the target platform format.

You can convert data with the following RMAN CONVERT commands:

CONVERT DATAFILE

CONVERT TABLESPACE

CONVERT DATABASE

  1. Converting Tablespaces on the Source System After Export

An example illustrates how to use the RMAN CONVERT TABLESPACE command to convert tablespaces to a different platform.

The example makes the following assumptions:

  1. The sales_1 and sales_2 tablespaces are being transported to a different platform.
  2. The endianness of the source platform is different from the endianness of the target platform.
  3. You want to convert the data on the source system, before transporting the tablespace set to the target system.
  4. You have completed the Data Pump export on the source database.

Complete the following steps to convert the tablespaces on the source system:

  1. At a command prompt, start RMAN and connect to the source database:

$ RMAN TARGET /

  1. Use the RMAN CONVERT TABLESPACE command to convert the data files into a temporary location on the source platform.

RMAN> CONVERT TABLESPACE sales_1,sales_2

TO PLATFORM 'Microsoft Windows IA (32-bit)'

FORMAT '/tmp/%U';

  1. Transfer the data files to the target system.

  1. Converting Data Files on the Target System Before Import

An example illustrates how to use the RMAN CONVERT DATAFILE command to convert data files to a different platform.

During the conversion, you identify the data files by file name, not by tablespace name. Until the tablespace metadata is imported, the target instance has no way of knowing the desired tablespace names.

The example makes the following assumptions:

  1. You have not yet converted the data files for the tablespaces being transported.
  2. The following data files are being transported to a different platform:

C:\Temp\sales_101.dbf

C:\Temp\sales_201.dbf

The data files must be accessible to the target database. If they are not accessible to the target database, then transfer the data files to the target system.

  1. The endianness of the source platform is different from the endianness of the target platform.
  2. You want to convert the data on the target system, before performing the Data Pump import.
  3. The converted data files are placed in C:\app\orauser\oradata\orawin\, which is the location of the existing data files for the target system:

Complete the following steps to convert the tablespaces on the target system:

Use the RMAN CONVERT DATAFILE command to convert the data files on the target platform:

$ RMAN TARGET /

RMAN> CONVERT DATAFILE 'C:\Temp\sales_101.dbf', 'C:\Temp\sales_201.dbf'

TO PLATFORM="Microsoft Windows IA (32-bit)"

FROM PLATFORM="Solaris[tm] OE (32-bit)"

DB_FILE_NAME_CONVERT='C:\Temp\', 'C:\app\orauser\oradata\orawin\'

PARALLELISM=4;

If the source location, the target location, or both do not use Oracle Automatic Storage Management (Oracle ASM), then the source and target platforms are optional. RMAN determines the source platform by examining the data file, and the target platform defaults to the platform of the host running the conversion.

If both the source and target locations use Oracle ASM, then you must specify the source and target platforms in the DB_FILE_NAME_CONVERT clause.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值