Solved

how to format sql plus output so values appear under column names

Posted on 2009-07-15
7
3,216 Views
Last Modified: 2013-12-07
Hi,

simple sql plus question

how do you format the columns in the ouput of sql plus so I can read them nicely from left to right
and under to appropriate column names?

my ouput is as show below
[oracle@host orcl]$ sqlplus / as sysdba
 

SQL*Plus: Release 11.1.0.6.0 - Production on Wed Jul 15 10:27:38 2009
 

Copyright (c) 1982, 2007, Oracle.  All rights reserved.
 
 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options
 

SQL> select name,compatibility,database_compatibility from v$asm_diskgroup;
 

NAME

------------------------------

COMPATIBILITY

------------------------------------------------------------

DATABASE_COMPATIBILITY

------------------------------------------------------------

DATA

10.1.0.0.0

10.1.0.0.0
 

FRA

10.1.0.0.0

10.1.0.0.0
 

NAME

------------------------------

COMPATIBILITY

------------------------------------------------------------

DATABASE_COMPATIBILITY

------------------------------------------------------------

Open in new window

0
Comment
Question by:ora-what
  • 4
  • 3
7 Comments
 
LVL 11

Accepted Solution

by:
Andytw earned 500 total points
Comment Utility
You need to use the "COL" SQL*Plus command,  with this you can control how a value/column is displayed or formatted.  Try the following:
col NAME format a10

col COMPATIBILITY format a15

col DATABASE_COMPATIBILITY format a15

Open in new window

0
 
LVL 11

Expert Comment

by:Andytw
Comment Utility
.. check out the following link for more information on the SQL*Plus "COLUMN" (COL for short) command:

SQL*Plus User's Guide and Reference
http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch12013.htm#sthref1926

Also, make sure that your LINESIZE SQL*Plus variable is set to a value large enough to accomodate your data:
e.g.
SET LINESIZE 140

Open in new window

0
 

Author Comment

by:ora-what
Comment Utility
alright, i seem to be having a problem

don't have time to look in the documentation


SQL> col NAME format a10                    
col COMPATIBILITY format a15
col DATABASE_COMPATIBILITY format a15SQL> SQL>  select name,compatibility,database_compatibility from v$asm_diskgroup;
SP2-0158: unknown COLUMN option "select"
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Closing Comment

by:ora-what
Comment Utility
A++
0
 
LVL 11

Expert Comment

by:Andytw
Comment Utility
did you hit return after the last col command?  col is a SQL*Plus comand and needs to be on separate lines from your sql statement.  The following works for me ...
SQL> col NAME format a10

SQL> col COMPATIBILITY format a15

SQL> col DATABASE_COMPATIBILITY format a15

SQL> select name,compatibility,database_compatibility from v$asm_diskgroup;
 

no rows selected
 

SQL>

Open in new window

0
 

Author Comment

by:ora-what
Comment Utility
it's OK now I did it

thanks :) !
0
 

Author Comment

by:ora-what
Comment Utility
yeah I didn't hit return , .. just pasted the whole thing in at once

1 line at a time works

thanks again !
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.

Join & Write a Comment

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

14 Experts available now in Live!

Get 1:1 Help Now