Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Is it possible to make SQLPlus autofit column display lengths?

Posted on 2009-03-28
4
Medium Priority
?
4,854 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
mrjoltcola earned 1500 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 48

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
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, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

609 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