Chinaunix首页 | 论坛 | 博客
  • 博客访问: 894787
  • 博文数量: 101
  • 博客积分: 2256
  • 博客等级: 大尉
  • 技术积分: 1481
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-19 17:52
文章存档

2017年(1)

2013年(2)

2012年(25)

2011年(73)

分类: Oracle

2011-04-26 22:17:19

做任何事情,都要知己知彼,至少得知道自己所处的环境,下面我
就介绍一下了解登录用户环境的oracle查询语句。
下面就是我在自己电脑上的一些实验;
SQL> --显示当前用户名;
SQL> show user;
USER 为 "SYS"
SQL> --显示当前实例名;
SQL> select instance_name from v$instance;
INSTANCE_NAME                                              
                   
----------------                                           
                   
orcl                                        
SQL> --显示当前实例名另外一种方法;         
SQL> select name from v$database;
NAME                                                       
                   
---------                                                  
                   
ORCL                                                       
                   
SQL> --查看现在的启动状态;
SQL> select status from v$instance;
STATUS                                                     
                   
------------                                               
                   
OPEN                                                       
                   
SQL> --使用USEREVN函数来返回当前用户的环境信息;
SQL> --查看当前用户是否是DBA如果是则返回true,我测试了后发
现只有sys用户是TRUE,其它都为FALSE;
SQL> select userenv('isdba') from dual;
USEREN                                                     
                   
------                                                     
                   
TRUE                                                       
                   
返回会话标志
SQL> select userenv('sessionid') from dual;
USERENV('SESSIONID')                                       
                   
--------------------                                       
                   
          4294967295                                       
                   
返回会话人口标志
SQL> select userenv('entryid') from dual;
USERENV('ENTRYID')                                         
                   
------------------                                         
                   
                 0                                         
                   
返回当前INSTANCE的标志
SQL> select userenv('instance') from dual;
USERENV('INSTANCE')                                        
                   
-------------------                                        
                   
                  1                                        
                   
返回当前环境变量
SQL> select userenv('language') from dual;
USERENV('LANGUAGE')                                        
                   
----------------------------------------------------       
                   
SIMPLIFIED CHINESE_CHINA.ZHS16GBK                          
                   
返回当前环境的语言的缩写
SQL> select userenv('lang') from dual;
USERENV('LANG')                                            
                   
----------------------------------------------------       
                   
ZHS                                                        
                   
返回用户的终端或机器的标志
SQL> select userenv('terminal') from dual;
USERENV('TERMINAL')                                        
                   
------------------------------                             
                   
BK-FDA996F2E2E9                                            
                   
返回X的大小(字节)数,这里sys表示3个字节;
SQL> select vsize(user),user from dual;
VSIZE(USER) USER                                           
                   
----------- ------------------------------                 
                   
          3 SYS                                            
                   

 
阅读(1276) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~