如何修改SQLPLUS提示符

来源:互联网 发布:ubuntu 16.04 mysql 编辑:程序博客网 时间:2024/06/14 11:34

如果你也想和我一样,在sqlplus登录数据库的时候,能提示不少像上面这样详细登录的信息:
1.登录的用户名。当你的数据库中有多个用户时,它能告诉你当前登录的是哪个用户。
2.登录的实例名。如果登录的rac,用这个能知道当前登录在哪个node。
3.登录主机的IP。有的时候,你可能登录在2台数据库主机上,2个数据库用户名相同,instance相同,只是数据库存在在不同的主机上——往往在数据库迁移的时候会遇到这样的情况。那么通过知道数据库主机的IP,将能防止你出错。

可以在$ORACLE_HOME/sqlplus/admin/glogin.sql文件中添加以上语句。


 

set sqlprompt'&gname> '

另一个设置,包含主机名

SELECT upper(USER) ||'@'||upper(instance_name)||'-'||HOST_NAME GLOBAL_NAME FROM v$instance;

or
SET SQLPROMPT "_USER'@'_CONNECT_IDENTIFIER > "

more Pre-Defined Variables:

_CONNECT_IDENTIFIER - Connection identifier used to establish the database connection
_DATE - Current date, or a user defined fixed string
_EDITOR - Specifies the editor that will be used when the EDIT command is executed
_O_VERSION - Oracle database version
_O_RELEASE - Full release number of the Oracle Database
_PRIVILEGE - The privilege level the current user has assigned to them
_SQLPLUS_RELEASE - Full release number of the SQL*PLUS program being used
_USER - Account name used to make the connection

0 0
原创粉丝点击