HOW TO SAVE DATA FAST

10 pts.
Tags:
Oracle Database
Oracle Output Via SQL
Oracle SQL
I have a query that retrieves 7 lakh rows of data in say 3 minutes but when i go to save this data in comma sepatrated file using toad's save as feature .it takes almost 3 hrs to save the data. This query looks like: SELECT circle_name,cluster_name,rsnnumber ,mdnnumber,hs_rsnnumber ,otafdate, (case when old_mdn is null then 'INACTIVE' else 'ACTIVE' end) FROM GSK_INVENTORYDETAILS WHERE OTAFDATE>='1-MAR-2009' AND OTAFDATE<='31-MAR-2009' AND GSKPLAN LIKE 'PREPAID%' AND CIRCLE_NAME='UTTAR PRADESH (WEST)' GSK_INVENTORYDETAILS has over 20 cr data I would like to know a way to save my data faster
ASKED: April 9, 2009  12:46 PM
UPDATED: April 15, 2009  12:14 AM

Answer Wiki

Thanks. We'll let you know when a new response is added.

You could try spooling the query’s output to a file in SQL*Plus, but you will need to make it ‘comma separated’.

This is an example:

<pre>set pagesize 20000;
spool c:\your_file.csv;
SELECT circle_name||’,'||cluster_name||’,'||rsnnumber||’,'||mdnnumber||’,'||hs_rsnnumber||’,'||otafdate||’,'||
(case when old_mdn is null then ‘INACTIVE’ else ‘ACTIVE’ end)
FROM GSK_INVENTORYDETAILS
WHERE OTAFDATE>=’1-MAR-2009′
AND OTAFDATE<=’31-MAR-2009′
AND GSKPLAN LIKE ‘PREPAID%’
AND CIRCLE_NAME=’UTTAR PRADESH (WEST)’
spool off;</pre>

Here I am assuming that the query will get 20000 records or less to set the pagesize. You should change it as needed.

After generating the file, you will need to remove all unnecesary text added at the beginning and end of the file.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following