开发者

Is there an equivalent of less for SQL*Plus?

开发者 https://www.devze.com 2023-01-11 09:02 出处:网络
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 res开发者_运维技巧ults?

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 res开发者_运维技巧ults?

select * from emp | less


SET PAUSE ON see http://www.developer.com/java/data/article.php/3369501/SQLPlus-Tips-for-Oracle-Beginners.htm


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消