How to limit select output from sqlplus

oraclesqlplus

I stop using SQL Developer as found more convenient to use SQL Plus inside Emacs SQLi mode.

SQL Developer on selects with large amount of rows show only few rows. But SQL Plus tend to dump all rows that match conditions. I can put ROWNUM <= N but I often forget to do this.

Is there any option for SQL Plus to limit it output from select statement? I will put it to /opt/instantclient/glogin.sql in order to apply to each sesstion…

Best Answer

I don't think you can. The only thing I know that sort of does that (but is slightly annoying IMO) is the PAUSE option which waits for you to press enter between pages. The annoying part is that it pauses before the first row... You can Ctrl C to interrupt when you've seen enough.

SQL> set pause on
SQL> set pages 10 pause 'press enter to continue'
SQL> select object_name from dba_objects;
press enter to continue

OBJECT_NAME
--------------------------------------------------------------------------------
ICOL$
I_USER1
CON$
UNDO$
C_COBJ#
I_OBJ#
PROXY_ROLE_DATA$
press enter to continue

OBJECT_NAME
--------------------------------------------------------------------------------
I_IND1
I_CDEF2
I_OBJ5
I_PROXY_ROLE_DATA$_1
FILE$
UET$
I_FILE#_BLOCK#
press enter to continue

I_FILE1
ERROR:
ORA-01013: user requested cancel of current operation

15 rows selected.