Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > How to set Tab as column separator in SQL*Plus?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-02-03, 07:28
peisiong peisiong is offline
Registered User
 
Join Date: Apr 2003
Posts: 19
How to set Tab as column separator in SQL*Plus?

Any advice or workarounds, greatly appreciated.

Cheers,

Pei
Reply With Quote
  #2 (permalink)  
Old 04-02-03, 08:11
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 4,874
Re: How to set Tab as column separator in SQL*Plus?

Quote:
Originally posted by peisiong
Any advice or workarounds, greatly appreciated.

Cheers,

Pei

You could do this:

SQL> column tab new_value tab
SQL> select chr(9) tab from dual;

T
-


SQL> set colsep "&tab"
__________________
Tony Andrews
http://tonyandrews.blogspot.com
Reply With Quote
  #3 (permalink)  
Old 04-02-03, 08:53
peisiong peisiong is offline
Registered User
 
Join Date: Apr 2003
Posts: 19
Re: How to set Tab as column separator in SQL*Plus?

[quote][size=1]Originally posted by andrewst
Thanks Andrew!!!
Reply With Quote
  #4 (permalink)  
Old 04-23-03, 11:18
peisiong peisiong is offline
Registered User
 
Join Date: Apr 2003
Posts: 19
tab as col separator

Hi

I have done what you have suggested and the spooled file looks ok when I open it in EXCEL.

But when I open it in a text editor, there seems to be spaces (lots of them) in place of tab.

Any idea why?

Cheers,

Pei Siong
Reply With Quote
  #5 (permalink)  
Old 04-23-03, 11:40
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 4,874
Re: tab as col separator

Quote:
Originally posted by peisiong
Hi

I have done what you have suggested and the spooled file looks ok when I open it in EXCEL.

But when I open it in a text editor, there seems to be spaces (lots of them) in place of tab.

Any idea why?

Cheers,

Pei Siong

There are spaces, as well as the delimiting TABs, because of the way SQL Plus formats the data WITHIN the columns, e.g.:

____DEPTNO|DNAME_________|LOC_________
----------|--------------|-------------
________10|ACCOUNTING____|NEW_YORK____
________20|RESEARCH______|DALLAS______
________30|SALES_________|CHICAGO_____
________40|OPERATIONS____|BOSTON______

(I have changed spaces to '_' and tabs to '|' so you can see better).

I'm not aware of any way to change this behaviour. A common way to get tab-delimited output without spaces is to select it that way:

SELECT deptno||CHR(9)||dname||CHR(9)||loc AS record
FROM dept;

RECORD
---------------------------------------------------------------------
10|ACCOUNTING|NEW YORK
20|RESEARCH|DALLAS
30|SALES|CHICAGO
40|OPERATIONS|BOSTON

Use SET TRIMSPOOL ON to remove the trailing spaces on the last column.
__________________
Tony Andrews
http://tonyandrews.blogspot.com
Reply With Quote
  #6 (permalink)  
Old 04-24-03, 09:44
peisiong peisiong is offline
Registered User
 
Join Date: Apr 2003
Posts: 19
tab as column delimiter

Hi andrew,

Thanks for your help. If I have 100+ columns in my select statement, will using concatenate affect the performance of the select?

Cheers,

Pete
Reply With Quote
  #7 (permalink)  
Old 04-24-03, 10:34
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 4,874
Re: tab as column delimiter

Quote:
Originally posted by peisiong
Hi andrew,

Thanks for your help. If I have 100+ columns in my select statement, will using concatenate affect the performance of the select?

Cheers,

Pete

Not as far as I know.
__________________
Tony Andrews
http://tonyandrews.blogspot.com
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On