Link to home
Start Free TrialLog in
Avatar of abemiester
abemiester

asked on

Is it possible to make SQLPlus autofit column display lengths?

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...
ASKER CERTIFIED SOLUTION
Avatar of mrjoltcola
mrjoltcola
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Naveen Kumar
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.
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
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.