1

I have a simple sql script file which only includes a SELECT statement. But the output of SELECT statement is huge (more than a few hundred thousands lines).

I cannot get output saved in a local file. I just changed my select statement to DESC and it worked fine, so the problem seems the size of output (select statement is something like SELECT * from TABLEX)

I will appreciate any comments on how to execute the select statement..

Thanks in advance


I updated my sql script file as below

SET SQLBLANKLINES ON
set echo off  
set feedback off  
set linesize 1000  
set pagesize 0  
set sqlprompt ''  
set trimspool on  
set headsep off  

spool output.csv  
select * from JM_WCEL_BTH_CURRENT  
SPOOL OFF  
EXIT

The output is below

D:\>sqlplus user/user@mydb @2.sql

SQL*Plus: Release 10.2.0.4.0 - Production on Thu Jan 17 10:10:15 2013

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, Data Mining and Real Application Testing options

  4
  5
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64
bit Production
With the Partitioning, Data Mining and Real Application Testing options

D:\>

There is nothing in the output file but numbers 4 and 5. I ended the process after a few minutes by pressing Ctrl + C. I also tried removing spooling process, there is no output to console as well.

I tried to run the sql query from ay other tool, it gives results in less than a second!

Any suggestions?

Thanks

1
  • Are you spooling the output to a file? What error do you get when spooling the file? Jan 16, 2013 at 5:53

2 Answers 2

1

We have successfully spooled 60 million rows to csv files using SQL*Plus, using something like this:.

set echo off
set feedback off
set linesize 1000
set pagesize 0
set sqlprompt ''
set trimspool on
set headsep off

spool output.csv

select 'col1,col2,col3' from dual;

select col1 || ',' || col2 || ',' || col3
from bigtable;

spool off

One problem that can happen with very long-running queries is the Oracle session times out, or the TCP connection gets clobbered by a firewall. If your query runs for hours you should probably look into these issues.

0
0

This is not related to performance or SQL*Plus limitations. It is simply missing semicolon at the end of executing command:

 select * from JM_WCEL_BTH_CURRENT; 
                                  ^
                                  |____________add semicolon here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.