Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Column headings keep appearing throughout Oracle output

Tags:

oracle

sqlplus

After ever 10 lines, my column headers reappear in my Oracle output. Is there something about my code or some kind of environment variable I can set to stop this? I only need the column headers to appear once at the top of my results.

BREAK ON Customer
COLUMN Customer -
       FORMAT A15 -
       HEADING 'Customer Name'
COLUMN "Charter Date" -
       HEADING 'Charter|Date'
COLUMN Pilot -
       FORMAT A20 -
       HEADING 'Pilot'
SELECT DECODE (cu.cus_initial,null, cu.cus_fname||' '||cu.cus_lname,
       cu.cus_fname||' '||cu.cus_initial||'. '||cu.cus_lname)
       AS Customer,
       ch.char_date "Charter Date",
       TRIM( e.emp_fname) ||' '|| TRIM(e.emp_lname) AS "Pilot"
FROM hartmar.customer cu,
     hartmar.charter ch,
     hartmar.crew cr,
     hartmar.pilot p,
     hartmar.employee e
WHERE cu.cus_code = ch.cus_code
      AND ch.char_trip = cr.char_trip
      AND cr.emp_num = p.emp_num
      AND p.emp_num = e.emp_num
      AND cr.crew_type = 'Pilot'
ORDER BY cu.cus_lname, cu.cus_fname, cu.cus_initial, ch.char_date
;

CLEAR BREAKS
CLEAR COLUMNS
like image 202
smiligrl Avatar asked Oct 01 '11 00:10

smiligrl


People also ask

How do I change column headings in Oracle?

To change a column heading to two or more words, enclose the new heading in single or double quotation marks when you enter the COLUMN command. To display a column heading on more than one line, use a vertical bar (|) where you want to begin a new line.

What is set heading off in Oracle?

Synopsis. The HEADING setting controls whether column headings print when you SELECT or PRINT data. The default value for this setting is ON, which allows column headings to print.

What does column (+) mean in Oracle?

The plus sign is Oracle syntax for an outer join. There isn't a minus operator for joins. An outer join means return all rows from one table. Also return the rows from the outer joined where there's a match on the join key. If there's no matching row, return null.


2 Answers

Assuming you're running this in SQL*Plus, you need to set your pagesize.

SET PAGESIZE 50000

will cause the columns headings to appear only once for every 50,000 rows returned. I believe 50,000 is the maximum PAGESIZE setting.

If you want to eliminate headers entirely, you can set the PAGESIZE to 0 but that will suppress even the first set of headers

SQL> set pagesize 0;
SQL> select ename, empno from emp;
PAV              7623
smith            7369
ALLEN            7499
WARD             7521
JONES            7566
MARTIN           7654
BLAKE            7698
CLARK            7782
SCOTT            7788
KING             7839
TURNER           7844
ADAMS            7876
SM0              7900
FORD             7902
MILLER           7934
BAR              1234

16 rows selected.
like image 160
Justin Cave Avatar answered Sep 22 '22 00:09

Justin Cave


Use a 'hidden' feature that will suppress all EXCEPT the first row of headings!

set pagesize 0 embedded on

Thanks to "Bruno Ruess" via https://community.oracle.com/thread/2389479?start=0&tstart=0 for the above.

If you then also add

SET UNDERLINE off

Then you can supress the "underlining" of the header row, and get to something that looks a lot more like a CSV.

like image 42
dsz Avatar answered Sep 25 '22 00:09

dsz