spooling data [message #541674] |
Wed, 01 February 2012 13:29 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
sant_new
Messages: 165 Registered: June 2008
|
Senior Member |
|
|
Hi friends,
I would like to use the Spool command to export data for other purposes within the application. We would like to use tab demiliter to seperate the fields but the cliient wants to know if the text datatype fields can be wrapped in double quotes along with the tab demiliter..
SQL>create table test (id number(2), first_name varchar2(15), last_name varchar2(15),var_no number(4),
type varchar2(1),type_no number(12));
Table created.
SQL> insert into test values(1,'mary','ross',132,'S',12);
1 row created.
SQL> insert into test values(3,'Sue','Bill',432,'S',12);
1 row created.
I tried the below spool command to use tab demilited for all the fields but not sure how to wrap double quotes for only the text fields and also would to have the column names in the 1st row but don't seem to get the full column name in the csv file.
set echo off
set feedback off
set linesize 1000
set pagesize 4000
set trim on
set headsep off
set colsep '' (used tab between the quote)
spool test.csv
select id,first_name,last_name,var_no,type,type_no from test;
spool off
Any help would be appreciated.. Thanks a lot
[Updated on: Wed, 01 February 2012 13:33] by Moderator Report message to a moderator
|
|
|
|
Re: spooling data [message #541676 is a reply to message #541675] |
Wed, 01 February 2012 14:42 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
sant_new
Messages: 165 Registered: June 2008
|
Senior Member |
|
|
Thanks a lot Michel. That was exactly what I was looking for. But when I try the same script for different tables with more number of records and more fields in the table, the column names in the 1st row is not displayed in full..
Is it possible to display the column names in full only in the 1st row?And is it possible to remove the dotted lines in the 2nd row?
Also, will there be any limitation in extracting big tables (about 2 million and 100+ columns) to CSV file?
Thanks a lot for all your help.
[Updated on: Wed, 01 February 2012 14:54] Report message to a moderator
|
|
|
|
|
|
|
|
Re: spooling data [message #541818 is a reply to message #541816] |
Thu, 02 February 2012 09:32 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
sant_new
Messages: 165 Registered: June 2008
|
Senior Member |
|
|
I'm trying to extract data from a table with 50+ fields, when I run the SQL I get:
SP2-0027: Input is too long (> 2499 characters)
I tried with SET SERVEROUTPUT ON SIZE UNLIMITED, still get the same error. Is there a limitation to extract large volume of data using spooling?
Thanks again
|
|
|
|
|