ITPub博客

首页 > 数据库 > 数据库开发技术 > 在SQLPLUS里显示相对应的用户名和实例名

在SQLPLUS里显示相对应的用户名和实例名

原创 数据库开发技术 作者:yuantong 时间:2007-09-12 08:32:15 0 删除 编辑

The following entries in either of these files sets the prompt to "user@database>"

define gname = 'not connected'
column global_name new_value gname
set termout off
select lower(user) || '@' || replace(global_name,'.WORLD',null) global_name
from global_name;
set termout on
set sqlprompt '&&gname> '

However, this is only run ONCE (when you login), so if you're the kind of person that issues "conn" or "connect" from within your SQL Plus session, you can then create two files

conn.sql
-----------
connect &1
@login

connect.sql
-----------
connect &1
@login

which will change your connection and then re-issue the prompt setting commands

scott@demo> @conn newuser/newpass
Connected.
newuser@demo>
我喜欢用这个

define gname = 'not connected'
column global_name new_value gname
set termout off
select lower(user) || '@' || utl_inaddr.get_host_address() || '@' || replace(global_name,'.WORLD',null) global_name
from global_name;
set termout on
set sqlprompt '&&gname> '
tong@19.200.1.33@OA>
[@more@]
                                                            

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12482/viewspace-969039/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-12-07

  • 博文量
    61
  • 访问量
    792597