Operating System - Linux
1752805 Members
5598 Online
108789 Solutions
New Discussion юеВ

Export table data to flat file

 
SOLVED
Go to solution
Gyankr
Frequent Advisor

Export table data to flat file

Hi,
I have an oracle db installed in a unix system. I want the table data to be exported to a flat file.The fields in the flat file need to be "PIPE separated".
Please let me know how to go about using bash shells. I have tried the reverse procedure (sql loaders).
8 REPLIES 8
James R. Ferguson
Acclaimed Contributor

Re: Export table data to flat file

Hi:

Well, if you already have whitespace (spaces and tab) delimited data, simply do:

# perl -nale 'print join "|",@F' file

Regards!

...JRF...
Gyankr
Frequent Advisor

Re: Export table data to flat file


Hi,
Thanks for your reply,that was very fast. I am not so well versed in perl,can you explain this using bash scripting
OldSchool
Honored Contributor

Re: Export table data to flat file

google turns up many suggestions on how to perform the unload. a couple are here:

http://asktom.oracle.com/tkyte/flat/index.html

http://www.withdata.com/oracmd_unload.html
James R. Ferguson
Acclaimed Contributor

Re: Export table data to flat file

Hi (again):

Well, in Perl, this reads your input file ('-n') and automatically splits each record into whitespace-delimited fields ('-a') into an array called '@F'. The fields of @F are then printed using the 'join' operator and a pipe delimiter. The '-l' switch adds a newline to each record as it is printed.

Regards!

...JRF...
Volker Borowski
Honored Contributor
Solution

Re: Export table data to flat file

Well,

this might help:
http://www.orafaq.com/faqloadr.htm#UNLOAD

but you may have to substitute

select col1 || ',' || col2 || ',' || col3

with

select col1 || '|' || col2 || '|' || col3

to get a pipe-delimited result.

Regards
Volker
Murat SULUHAN
Honored Contributor

Re: Export table data to flat file

Hi Raju

Check following url
http://www.oracle-bse.com/articles/9i/GeneratingCSVFiles.php

utl_file is excellent for this issue.

Best Regards
Murat

Murat Suluhan
Gyankr
Frequent Advisor

Re: Export table data to flat file

Hello everybody,
Thanks my is Problem solved -used the utl package in plsql

Thanks,
Gyan
Gyankr
Frequent Advisor

Re: Export table data to flat file

Problem solved