I’ve enjoyed quite a few of the tips in other people’s Oracle-related blogs (see the links in the right hand pane) so thought I’d chuck in a few as well. This one’s an old one, so many of you will know about it already, but for those that don’t …
In sqlplus, you can use ? as a substitute for the ORACLE_HOME location when running scripts, so when you want to run common supplied dictionary scripts (for example, to create the EXCEPTIONS table) you can use the following :-
SQL> connect scott/tiger
Connected.
SQL> @?/rdbms/admin/utlexcpt
Table created.
It’s a way to avoid remembering and typing in long directory paths such as /usr/oracle/app/product/9.2.0.6/rdbms/admin. It also means that you’ll be running the script from the correct directory for the version you’re working with.
However (and this is very important), as Jeff Hunter pointed out in his comment :-
“But watch out when you’re not on the server itself. For example, if your client is /usr/local/oracle which is a 9.2.0.6 ORACLE_HOME and your database is /oracle/product/10.2.0.1 you certainly don’t want to run @?/rdbms/catalog.”
Thanks, Jeff.
Another useful tip is to use @@ instead of @ if you want a script to call other scripts, because it’ll look for the scripts in the same directory as the calling script without you needing to supply the path.
But watch out when you’re not on the server itself. For example, if your client is /usr/local/oracle which is a 9.2.0.6 ORACLE_HOME and your database is /oracle/product/10.2.0.1 you certainly don’t want to run @?/rdbms/catalog.
Excellent point, Jeff, thanks. Although I might know that, it’s a trap that would be really easy to fall into.
In fact it’s so important, I think I’d better change the original posting, to be safe. No attempt at deception, I’ll make it clear where the correction/clarification came from.
Cheers.
Doug
Let’s just say I learned that by experience.