Column headings keep appearing throughout Oracle output

六月ゝ 毕业季﹏ 提交于 2020-04-12 12:51:25

问题


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

回答1:


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.



回答2:


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.




回答3:


You can also:

SET PAGESIZE 0

To stop all column headers after the start of your report.



来源:https://stackoverflow.com/questions/7617396/column-headings-keep-appearing-throughout-oracle-output

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!