DBMS_FILE_TRANSFER Package in Oracle Database 10g
来源:互联网 发布:saycam深孔钻编程 编辑:程序博客网 时间:2024/06/06 19:37
from:http://www.oracle-base.com/articles/10g/FileTransfer10g.php Oracle 10g has introduced the All of the the currently supported procedures have some common usage notes listed below: The Checking the destination directory will reveal that the file has been copied successfully. The Checking the destination directory on the local server will reveal that the file has been copied successfully. The Checking the destination directory on the remote server will reveal that the file has been copied successfully.DBMS_FILE_TRANSFER Package in Oracle Database 10g
DBMS_FILE_TRANSFER
package which provides an API for copying binary files between database servers.Common Usage Notes
V$SESSION_LONGOPS
view. COPY_FILE
COPY_FILE
procedure allows you to copy binary files from one location to another on the same server.-- Create the source and destination directory objects.CREATE OR REPLACE DIRECTORY db_files_dir1 AS '/u01/oradata/DB10G/';CREATE OR REPLACE DIRECTORY db_files_dir2 AS '/u02/oradata/DB10G/';-- Switch a tablespace into read only mode so we can-- use it for a test file transfer.ALTER TABLESPACE users READ ONLY;-- Copy the file.BEGIN DBMS_FILE_TRANSFER.COPY_FILE( source_directory_object => 'DB_FILES_DIR1', source_file_name => 'USERS01.DBF', destination_directory_object => 'DB_FILES_DIR2', destination_file_name => 'USERS01.DBF');END;/-- Switch the tablespace back to read write mode.ALTER TABLESPACE users READ WRITE;
GET_FILE
GET_FILE
procedure allows you to copy binary files from a remote server to the local server.-- Login to the remote server.CONN system/password@remote-- Create the source directory object and switch mode of a tablespace.CREATE OR REPLACE DIRECTORY db_files_dir1 AS '/u01/oradata/DB10G/';ALTER TABLESPACE users READ ONLY;-- Login to the local server.CONN system/password@local-- Create the destination directory object and a database link.CREATE OR REPLACE DIRECTORY db_files_dir2 AS '/u02/oradata/DB10G/';CREATE DATABASE LINK remote CONNECT TO system IDENTIFIED BY password USING 'REMOTE';-- Get the file.BEGIN DBMS_FILE_TRANSFER.GET_FILE( source_directory_object => 'DB_FILES_DIR1', source_file_name => 'USERS01.DBF', source_database => 'REMOTE', destination_directory_object => 'DB_FILES_DIR2', destination_file_name => 'USERS01.DBF');END;/-- Login to the remote server.CONN system/password@remote-- Switch the tablespace back to read write mode.ALTER TABLESPACE users READ WRITE;
PUT_FILE
PUT_FILE
procedure allows you to copy binary files from the local server to a remote server.-- Login to the remote server.CONN system/password@remote-- Create the destination directory object.CREATE OR REPLACE DIRECTORY db_files_dir2 AS '/u02/oradata/DB10G/';-- Login to the local server.CONN system/password@local-- Create the source directory object, database link and switch mode of a tablespace.CREATE OR REPLACE DIRECTORY db_files_dir1 AS '/u01/oradata/DB10G/';CREATE DATABASE LINK remote CONNECT TO system IDENTIFIED BY password USING 'REMOTE';ALTER TABLESPACE users READ ONLY;-- Put the file.BEGIN DBMS_FILE_TRANSFER.PUT_FILE( source_directory_object => 'DB_FILES_DIR1', source_file_name => 'USERS01.DBF', destination_directory_object => 'DB_FILES_DIR2', destination_file_name => 'USERS01.DBF', destination_database => 'REMOTE');END;/-- Switch the tablespace back to read write mode.ALTER TABLESPACE users READ WRITE;
DBMS_FILE_TRANSFER an ORACLE BUILD-IN package june 22, 2007
from:http://www.e-ammar.com/dbms_file_transfer.htm
this is a nice package that you can use to transfer file between directories within a local server or with directories within a local server and remote server.
Since, this package is designed to transfer Oracle database file (making up tablespace) between different instances of databases, it assumes that Oracle database is running on the location where the files are manipulated (on both local and remote if you are doing across server transfer). Or at least the listener must be running (i would assume)
dbms_file_transfer:
There are three procedures within the dbms_file_transfer package:
COPY_FILE: This is useful for copying files locally on the database server.
GET_FILE: This is useful when a file on a remote database is to be transferred to a local file system through the local database connection.
PUT_FILE: Reads a local file and contacts a remote database to create a copy of the file in the remote file system
CREATE DIRECTORY DEST_DIR AS '/u01/src';
CREATE DIRECTORY SOURCE_DIR AS '/home/oracle/infra/oradata';
As user SYS, create the necessary grants.
GRANT EXECUTE ON DBMS_FILE_TRANSFER to DBA
GRANT READ ON DIRECTORY SOURCE_DIR to DBA
GRANT WRITE ON DIRECTORY DEST_DIR to DBA
.As the DBA user, execute the following command.
BEGIN
dbms_file_transfer.copy_file( source_directory_object => 'SOURCE_DIR',
source_file_name => 'users1.dbf',
destination_directory_object => 'DEST_DIR',
destination_file_name => 'users1.dbf');
END;
/
The following example is to GET a file from a remote server
BEGIN
dbms_file_transfer.copy_file( source_directory_object => 'SOURCE_DIR',
source_file_name => 'users1.dbf',
source_database =>'DB1_LINK',
destination_directory_object => 'DEST_DIR',
destination_file_name => 'users1.dbf');
END;
/
Note: the source_database is identified as a database link that can be created using the following syntax
CREATE DATABASE LINK db1_link CONNECT TO user1 IDENTIFIED BY userpass USING 'linux'; -- linux is the connect string name in tnanames.ora file
- DBMS_FILE_TRANSFER Package in Oracle Database 10g
- Services in Oracle Database 10g
- DML Error Logging in Oracle 10g Database Release 2
- DML Error Logging in Oracle 10g Database Release 2
- Automatic Storage Management (ASM) in Oracle Database 10g
- SQL Access Advisor in Oracle Database 10g
- Virtual Columns in Oracle Database 11g
- using audit in oracle database 11g
- Oracle Database 11G Services in Windows
- Virtual Columns in Oracle Database 11g
- Using Transparent Database Encryption in Oracle Database 11g
- Oracle Database 10g安装
- 卸载 Oracle DataBase 10g
- Oracle Database 10g SQL
- Oracle Database 10g体系结构
- Oracle Database 10g 043
- Oracle by Example - Oracle Database 10g Release 2 on a Single Database Instance (All In One CHM)
- OCP 论证书籍 -- ORACLE DATABASE 10G OCP Certification All-in - One Exam Guide
- 深入理解PHP之源码目录结构
- 收集信息处理信息思考
- (转载)发现问题解决问题思考
- 工作总结
- NetBeans 时事通讯(刊号 # 74 - Sep 30, 2009)
- DBMS_FILE_TRANSFER Package in Oracle Database 10g
- (转载)技术路线的选择重要但不具有决定性
- Flex入门1-HelloWorld
- 在Windows 7中安装Visual Studio 2008 Team System 经验
- 庆祝国庆:中华人民共和国60周年
- 无聊
- Java数组实现循环队列
- Moodle进入Web Platform Installer 2.0
- CERTIFICATION ID CARD