Friday, May 8, 2009

Oracle Script to extract data from a table to a file - Putty | UNIX .

Oracle Script to extract data from a table to a file in Putty .

Save below script in to a file let me name it as extract.sql .

Latter follow below steps to run above file.

Sqlplus username/password@databaseName

You will login in to this database and just use below syntax to run it.

@extract.sql

Depending on the data whatever size it may be it will be saved in to the file (given in the file)

SCRIPT:

set head off verify off termout off echo off feedback off pagesize 0 linesize 30000 trimspool on

set colsep |

define fname=filename.log

spool &fname

select 'Custname||'|'||Custaddress||'|'||Custaddress2||'|'||Custsubmittedname||'|'||Custsubmittedaddress1||'|'||Custsubmittedaddress2||'|'||Custaddress_error' from dual;

select Custname||'|'||Custaddress||'|'||Custaddress2||'|'||Custsubmittedname||'|'||Custsubmittedaddress1||'|'||Custsubmittedaddress2||'|'||Custaddress_error from CustomerAddressTable

spool off

No comments:

Post a Comment

Code Formater

Paste Here Your Source Code
Source Code Formatting Options
1) Convert Tab into Space :
2) Need Line Code Numbering :
3) Remove blank lines :
4) Embeded styles / Stylesheet :
5) Code Block Width :
6) Code Block Height :
7) Alternative Background :
Copy Formatted Source Code
 
Preview Of Formatted Code