We are trying to figure out how to change the SQL*Plus prompt to dynamically reflect the instance name (SID) every time we switch databases. On Unix, I would have set an environment variable but I am not sure how to do this in a Windows 2000 environment.
I have a script called "login.sql" that gets executed every time I logon to a database with SQL*Plus. You can create this file anywhere you want. Just make sure that its directory is in your SQLPATH environment variable. This holds true on both Unix and Windows environments. Then, in your login.sql file, put the following lines of code:
COLUMN value NEW_VALUE _SID SELECT DECODE(INSTR(global_name,'.'),0,global_name, SUBSTR(global_name,1,INSTR(global_name,'.')-1)) AS value FROM global_name; SET SQLPROMPT "&_SID SQL> "Now, when you sign on to SQL*Plus, you will get the database SID in your prompt. You can further customize the login.sql file to set up your SQL*Plus environment before you get the prompt.
For More Information
- Dozens more answers to tough Oracle questions from Brian Peasland are available.
- The Best Oracle Web Links: tips, tutorials, scripts, and more.
- Have an Oracle or SQL tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical Oracle and SQL questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
Dig Deeper on Oracle database design and architecture
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.