签到成功

知道了

CNDBA社区CNDBA社区

Oracle 19C 查询 非系统 用户

2023-04-03 23:02 1029 0 原创 Oracle 19c
作者: dave

在Oracle 进行运维时,有时我们需要排除系统用户,在Oracle 11g以前的版本,可以通过如下查询来查询非系统用户:

SQL>set pages 200
SQL>select username,default_tablespace from dba_users where username not in ('SYS','SYSTEM','OUTLN','FLOWS_FILES','MDSYS','ORDSYS','EXFSYS','DBSNMP','WMSYS','APPQOSSYS','APEX_030200','ORDDATA','CTXSYS','ANONYMOUS','XDB','ORDPLUGINS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','MDDATA','DIP','APEX_PUBLIC_USER','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','MGMT_VIEW','SCOTT','SYSMAN','OWBSYS_AUDIT','OWBSYS');

在Oracle 12c以后,Oracle 增强了dba_users视图,引入了INHERITED列。http://www.cndba.cn/dave/article/116520

https://docs.oracle.com/en/database/oracle/oracle-database/12.2/refrn/DBA_USERS.htmlhttp://www.cndba.cn/dave/article/116520

Indicates whether the user definition was inherited from another container (YES) or not (NO)。
This column is available starting with Oracle Database 12c Release 2 (12.2.0.1).http://www.cndba.cn/dave/article/116520http://www.cndba.cn/dave/article/116520

所以我们可以直接利用该字段来查询非系统用户:

http://www.cndba.cn/dave/article/116520

SQL>select username from dba_users where INHERITED=’NO’;http://www.cndba.cn/dave/article/116520http://www.cndba.cn/dave/article/116520

http://www.cndba.cn/dave/article/116520

当然,也可以利用如下SQL来实现:http://www.cndba.cn/dave/article/116520

SQL>SELECT username,account_status from dba_users where account_status = ‘OPEN’ and username not like ‘%SYS%’ and username not like ‘C##%’ and username not like ‘PDBADMIN’ and username not like ‘DBSNMP’;

这里主要是多租户这块的用户,关于该特性的更多说明,可以参考我的数据:

《Oracle 18c 必须掌握的新特性》
https://www.cndba.cn/dave/article/3453http://www.cndba.cn/dave/article/116520

版权声明:本文为博主原创文章,未经博主允许不得转载。

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
dave

dave

关注

人的一生应该是这样度过的:当他回首往事的时候,他不会因为虚度年华而悔恨,也不会因为碌碌无为而羞耻;这样,在临死的时候,他就能够说:“我的整个生命和全部精力,都已经献给世界上最壮丽的事业....."

  • 2239
    原创
  • 3
    翻译
  • 547
    转载
  • 186
    评论
  • 访问:6633250次
  • 积分:4249
  • 等级:核心会员
  • 排名:第1名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ