views:

41

answers:

2

Sometimes a query on SQL*Plus might yield too many rows t fit on the screen.

Is there some equivalent of "piping to less/more" mechanism that I can do to navigate the results?

select * from emp | less
+1  A: 

Does SQL*Plus not allow you to run its commands from the shell? It's been a while since I used it but I though it did.

I know with DB2 you can just do:

db2 'select * from sysibm.sysdummy1' | less

at the command line and let the shell handle the paging.

If not, I'd just create an sql++ script like:

#!/usr/bin/bash
echo connect pax/diablo >/tmp/sql++.$$
echo "$@" >>/tmp/sql++.$$
sqlplus @/tmp/sql++.$$
rm -rf /tmp/sql++.$$

and use it:

sql++ 'select * from dual' | less

That way you get the full power of less paging, being able to scroll up and down, search and so on.

paxdiablo