Page 1 of 1

how to trfr a file into db and and db file to os

Posted: Wed Nov 21, 2007 3:57 am
by vangala.jpreddy
Dear Gurus,

Please explain me How to Transfer OS file into database and how to transfer database table into os file. If you have any documentation please forward me.

Thanks in advance.
Jayaprakash.

Posted: Wed Jan 09, 2008 12:41 pm
by amirtai
Hi there

SQL*Loader is a bulk loader utility used for moving data from external files into the Oracle database.

Oracle does not supply any data unload utilities. However, you can use SQL*Plus to select and format your data and then spool it to a file:

set echo off newpage 0 space 0 pagesize 0 feed off head off trimspool on
spool oradata.txt
select col1 || ',' || col2 || ',' || col3
from tab1
where col2 = 'XYZ';
spool off

Alternatively use the UTL_FILE PL/SQL package:

rem Remember to update initSID.ora, utl_file_dir='c:\oradata' parameter
declare
fp utl_file.file_type;
begin
fp := utl_file.fopen('c:\oradata','tab1.txt','w');
utl_file.putf(fp, '%s, %s\n', 'TextField', 55);
utl_file.fclose(fp);
end;
/

Hope that would be helpful.

Amir