oracle 在 SQL*Plus 中,如何更改提示以显示连接的用户和数据库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/303940/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 01:38:42  来源:igfitidea点击:

In SQL*Plus, how do I change the prompt to show the connected user and database?

oraclesqlplus

提问by cagcowboy

To show, for example....

例如,要显示......

USER@SID > 

I thought this was potentially helpful to a few people so I'm going to answer it too!

我认为这对一些人可能有帮助,所以我也将回答它!

回答by cagcowboy

Amend your $ORACLE_HOME\sqlplus\admin\glogin.sql script - add:

修改您的 $ORACLE_HOME\sqlplus\admin\glogin.sql 脚本 - 添加:

set sqlprompt "_user '@' _connect_identifier > "

to the end of the file.

到文件末尾。

In Oracle 10g this will change correctly each time you issue a "conn". For clients before 10g it won't change when you do a "conn" but will remain as the username/db you first connected to.

在 Oracle 10g 中,每次发出“conn”时,这都会正确更改。对于 10g 之前的客户端,当您执行“conn”时它不会改变,但会保留为您第一次连接的用户名/数据库。

You can also use _date for the current date and _privilege for the privilege (eg SYSDBA) of the connected user.

您还可以使用 _date 表示当前日期,使用 _privilege 表示已连接用户的权限(例如 SYSDBA)。

Reference:

参考:

http://www.acs.ilstu.edu/docs/Oracle/server.101/b12170/whatsnew.htm

http://www.acs.ilstu.edu/docs/Oracle/server.101/b12170/whatsnew.htm