Solved

Is it possible to make SQLPlus autofit column display lengths?

Posted on 2009-03-28
4
2,758 Views
Last Modified: 2013-12-07
I'm new to oracle and I would like to know if it's possible to set the following display options and if so how.

1) One record to one line (no line wrapping)

2) Have the display width of each column set to the length of the largest item in that column.
Example:
I have a column called description that can be 1000 characters long.  There are 15 rows returned in my query and the longest description is 35 characters.  Can I have the column display width set to 35?  I know I can set this manually, but I don't want to do it for every query...
0
Comment
Question by:abemiester
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
mrjoltcola earned 500 total points
ID: 24013881
1) You can set linesize to a really long size, before you spool it.

set line 500

2) I don't think so, I've never seen it. I only know the syntax to set a column format prior to running the query.

column DESCRIPTION a35

select DESCRIPTION from table


http://www.adp-gmbh.ch/ora/sqlplus/column.html
0
 
LVL 28

Expert Comment

by:Naveen Kumar
ID: 24015687
Regarding question 2,

there is no automated way to set the column legth to max length depending on your data in the table column.

We need to do it manually only in sql*plus. But in TOAD or SQL/PLSQL Developer etc, you should have some option for setting that automatically depending on your data.
0
 
LVL 28

Expert Comment

by:Naveen Kumar
ID: 24015810
regading 1,

you can do as shown below :

SQL> set wrap off

for more information, refer to the below oracle documentation on sql*plus commands

http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch12040.htm#sthref2952
0
 
LVL 47

Expert Comment

by:schwertner
ID: 24019183
You can estimate the maximum length of a the column so

SELECT max(length(column_name)) INTO v_variable from my_table;

If you use this value possibly using 'execute immediate' statement it will be possible
to set the environment. But I am not sure about this.

The best choice is to set to a big value:

set linesize 10000

Normally every record is displayed in one line, so
I do not think you will face problems at all.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now