Is there an equivalent of less for SQL*Plus?

我只是一个虾纸丫 提交于 2019-12-11 01:15:08

问题


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:


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




回答2:


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.



来源:https://stackoverflow.com/questions/3446349/is-there-an-equivalent-of-less-for-sqlplus

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