SQL*Plus is not that pretty, you can always use RPAD to fill empty spaces and align all columns given a fixed width.
Main Topics
Browse All TopicsI would like to output my column headings and data neatly, with one or two spacings apart between columns, all on one line, if possible. My problem is that I can't seem to get the headings and the columns to line up properly. I have to mess with spaces to try to get them to line up. It is very frustrating. I would greatly appreciate it if someone could help me with this. The widths of my columns are as follows"
SWRREQD_SBGI_CODE NOT NULL VARCHAR2(6 CHAR)
SWRREQD_ACYR_CODE NOT NULL VARCHAR2(4 CHAR)
SWVSBGI_DESC NOT NULL VARCHAR2(60 CHAR)
SWRREQD_DEGT_TRNS NOT NULL VARCHAR2(6 CHAR)
SWVDEGT_DESC NOT NULL VARCHAR2(100 CHAR
SWRREQD_DEGC_INST NOT NULL VARCHAR2(6 CHAR)
SWRREQD_MAJR_CODE NOT NULL VARCHAR2(4 CHAR)
STVMAJR_DESC VARCHAR2(30 CHAR
SWRREQD_CONC_CODE NOT NULL VARCHAR2(4 CHAR)
SWRREQD_SEQNO NOT NULL NUMBER(3,1)
SWRREQD_SUBJ_CODE NOT NULL VARCHAR2(60 CHAR)
SWRREQD_CRSE_NUMB NOT NULL VARCHAR2(60 CHAR)
SWRREQD_COUNTER NOT NULL NUMBER(3,1)
Count(*)
Eventhough the description (DESC) columns are of length 60 or 100, I only really need the first 40 characters because the rest all a blank. The SUBJ_CODE and CRSE_NUMB columns are shown of length 60, but in reality they only take up 5 characters. I attempted to write my code as shown below, but I have had to put in leading blanks before the column titles to try to get them to line up. I know there should be a better way.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
flow01 and Pal2ie, I used RPAD (actually LPAD) like you suggested and it helped me adjust the output from the columns so that they lined up with the headings. However, I still had to make the adjustments with a lot of trial and error because I still can't figure out exactly how it works with the format column command I used at the top.
Business Accounts
Answer for Membership
by: flow01Posted on 2009-09-30 at 13:43:02ID: 25463386
In what tool are yor executing the sql ?
Do you have an example of the output you get ?