When I run a sql statement which supposed to return exact one row, sqlplus print column names many many times ? why ?
At the SQL*Plus command line, type: set pagesize 30 - this will change the page size to 30 rows. set pause on - this will cause the output to pause every 30 lines; press the enter key to continue.
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.
To do this we use a procedure called dbms_output. put_line to place the results in a buffer that SQL*Plus will retrieve and display. SQL*Plus must be told to retrieve data from this buffer in order to display the results. The SQL*Plus command 'set serveroutput on' causes SQL*Plus to retrieve and display the buffer.
Probably because your pagesize is much smaller than the number of lines necessary to display the data, due to wrapping. It repeats the heading on each "page" of output, even if it has not completed displaying a single row.
For the purpose of seeing/copy-pasting an entire output as a whole, try SET PAGESIZE 10000
(or some other large number).
For exploring the output in the console, you'd probably want to set it to your console window's height instead (you guessed it - the real "page size"). This way, you'll see exactly one set of headers, whichever place in the output you're in - which is exactly this statement's purpose.
A closely-related command is SET LINESIZE
- output width.
Because of its configuration. You can set sqlplus behaviour via SET:
http://ss64.com/ora/syntax-sqlplus-set.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With