Friday, March 7, 2014

Accessing ASM Files by Using DBMS_FILE_TRANSFER

The DBMS_FILE_TRANSFER package provides procedures to copy ASM files within a database or transfer binary files between databases that use ASM. The DBMS_FILE_TRANSFER package has the following procedures:

  • COPY_FILE: Reads a file from a source directory and creates a copy of the file in a destination directory. The source and destination directories can both be in a local file system or in an ASM disk group. You can also use this procedure to copy between a local file system and an ASM disk group; the copy operation is valid in either direction.
  • GET_FILE: Contacts a remote database to read a remote file and then creates a copy of the file in the local file system or ASM disk group
  • PUT_FILE: Reads a local file or ASM disk group and contacts a remote database to create a copy of the file in the remote file system
When using DBMS_FILE_TRANSFER, note the following:
  • The size of the copied file must be a multiple of 512 bytes.
  • The size of the copied file must be less than or equal to two terabytes.
  • Transferring a file is not transactional. To guarantee consistency, bring files offline when the database is in use.
  • The copied file is treated as a binary file, and no character set conversion is performed.



Example:

Copy a local database file into ASM.

SQL> CREATE DIRECTORY dgb AS '+DATA/dbfiles';
SQL> CREATE DIRECTORY loc AS '/u01/app/oracle/oradata/db';
SQL> BEGIN
2 DBMS_FILE_TRANSFER.COPY_FILE('loc','tmp.dbf','dgb','tmp.dbf');
3 END;
4 /





No comments:

Post a Comment