How to set the style of the SQLPLUS prompt

Source: Internet
Author: User
Abstract: in daily work, I think MySQL plus is used in 99% to log on to your database and manage, optimize, configure, and maintain the database. If there are more than n databases

Abstract: in daily work, I think MySQL plus is used in 99% to log on to your database and manage, optimize, configure, and maintain the database. If there are more than n databases



What is the local mode? It only works in the current directory. For example, we configure login in the current directory. SQL file, then the sqlplus tool will load login in the current directory. the SQL file prompt will take effect, and login in other directories will not take effect
1. Create a login. SQL file in the current directory.
Example: vim/home/oracle/login. SQL
2. Edit the login. SQL file and add a line of strings
Set sqlprompt "_ user' @ '_ connect_identifier>"
Or set sqlprompt '_ user @ & _ connect_identifier>'
Meaning: _ user represents the current Login user Name, _ connect_identifier represents the current database connection string name, and set the global sqlplus prompt in glogin. SQL to indicate that user and connect identifier are the default variables of sqlplus.
Note: At this time, it is set to take effect by logging on to the sqlplus tool prompt in the current directory, @ Replace with [$/#/& all], and entering sqlplus from another directory does not load the prompt variable
3. Save & Exit
4. sqlplus/as sysdba
Sys @ mdsoss>
5. Local beta version
If we log on to sqlplus in another directory, we have found the difference and restored to the original state.
Sqlplus/as sysdba
SQL>

3. Specify the user name and Instance name Method
1. Edit the glogin. SQL and login. SQL files, and add the following content at the end.
Set term off
Define user_name = ""
Define instance_name = ""
Column user_name new_value user_name
Column instance_name new_value instance_name
Select lower (user) user_name, instance_name from v $ instance;
Set sqlprompt '& user_name @ & instance_name>'
Note: -- user_name indicates the username currently logged on, and instance_name indicates the name of the currently logged on instance.
Sys @ mdsoss> @ Replace [$/#/& all]
2. Use sqlplus to log on to the database
In this way, you can specify the user name and Instance name when logging on to and switching users.
Enter value for user: liusheng
Enter value for instance_name: leonarding
Liusheng @ leonarding>
Summary: using the above methods can make us feel comfortable in the database ocean. We can also add them during normal exercises to form a habit, in this way, when you connect to different databases, you won't know which database to connect.

Leonarding Liu Sheng
2012.03.28
Tianjin & spring
Sharing Technology ~ Achieving dreams
Blog:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.