1

How do I shorten the type and name column when using the desc command?

SQL> desc owner
 Name                                                              Null?`    Type
----------------------------------------------------------------- -------- --------------------------------------------
OWNER_NUM                                                         NOT NULL  CHAR(4)
LAST_NAME                                                                   CHAR(50)
FIRST_NAME                                                                  CHAR(20)
ADDRESS                                                                     CHAR(15)
CITY                                                                        CHAR(15)
STATE                                                                       CHAR(2)
ZIP                                                                         CHAR(5)

It's really inconvenient when I have the command window snapped to half my screen.

Update

Using column Type format a15 doesn't work. My line size is already set to 120. Column commands work on all other tables I have encountered but the table retrieved from desc doesn't respond to column commands in the syntax I tried above.

Update

set wrap off doesn't work either.

Blu
  • 101
  • 12
  • Possible duplicate of [How to prettify the output coming from the SELECT query in command prompt?](http://stackoverflow.com/questions/14547501/how-to-prettify-the-output-coming-from-the-select-query-in-command-prompt) – Jon Heller Mar 06 '16 at 02:52
  • @JonHeller Nope. My line size is set to 120 and column commands don't work on the result of the `desc` command. At least, not in the syntax I tried it. – Blu Mar 06 '16 at 03:04
  • Woops, sorry. I retracted my close vote. – Jon Heller Mar 06 '16 at 03:39
  • You could use [your own query instead](http://stackoverflow.com/a/29670698/266304), as a script on your SQLPATH you can run with@; or as a function. – Alex Poole Mar 06 '16 at 09:04

1 Answers1

2

Change your linesize to a shorter size.

For example:

set linesize 80

or

set linesize 60

This appears to be the only solution, per the SQL*Plus User's Guide and Reference section on DESCRIBE:

To control the width of the data displayed, use the SET LINESIZE command.

Columns output for the DESCRIBE command are typically allocated a proportion of the linesize currently specified. Decreasing or increasing the linesize with the SET LINESIZE command usually makes each column proportionally smaller or larger. This may give unexpected text wrapping in your display. For more information, see the SET command.

Jon Heller
  • 34,999
  • 6
  • 74
  • 132
Ditto
  • 3,256
  • 1
  • 14
  • 28
  • I guess it could work but that doesn't change the fact that the columns in the table retrieved by `desc` are way too long. I was looking for more of a column command that works for `desc` but it may be my only option if stack overflow can't come up with an alternative. – Blu Mar 06 '16 at 03:19