Solved

Is it possible to make SQLPlus autofit column display lengths?

Posted on 2009-03-28
4
2,570 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

Title # Comments Views Activity
Oracle 12c patching 1 61
File generation using utl_file 4 46
Oracle sql query 7 49
1 FROM DUAL wont work with additional columns ?? 4 26
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many‚Ķ
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.

895 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

16 Experts available now in Live!

Get 1:1 Help Now