今天遇到个问题,创建了一个公共用户,权限也给了,但是查询表和SYS查询出来的结果就是不一样。哪怕是给了所有sys拥有的权限也还是不行。
例子
#创建用户
create user c##xinmonitor identified by 1232423;
#赋权
SQL> grant connect,resource,dba,pdb_dba,cdb_dba,create session to c##xinmonitor container=all; Grant succeeded.
#查询数据
SYS:
SQL> select count(*) from CDB_PROPERTIES; COUNT(*) ---------- 196
非SYS:
SQL> conn c##xinmonitor/ZhixinTech888 Connected. SQL> select count(*) from CDB_PROPERTIES; COUNT(*) ---------- 38
#以SYSDBA用户身份登录
SQL> conn c##xinmonitor/ZhixinTech888 as sysdba Connected. SQL> select count(*) from CDB_PROPERTIES; COUNT(*) ---------- 196
#以sysoper身份登陆
SQL> conn c##xinmonitor/ZhixinTech888 as sysoper Connected. SQL> select "PROPERTY_NAME","PROPERTY_VALUE","DESCRIPTION","CON_ID" from containers(dba_tables); SQL> select count(*) from CDB_PROPERTIES; select count(*) from CDB_PROPERTIES * ERROR at line 1: ORA-00942: table or view does not exist
这下数据就和SYS用户查出来的结果是一样的了,也是想要的结果。
2.问题原因
该视图的创建语句
create or replace view cdb_properties as select "PROPERTY_NAME","PROPERTY_VALUE","DESCRIPTION","CON_ID" from containers(DATABASE_PROPERTIES);
用到了新特性containers,
官网上有说明:containers里面指定的表/视图的所有者一定是连接查询的公共用户
Each table and view specified in the CONTAINERS
clause must be owned by the common user issuing the statement. When a synonym is specified in the CONTAINERS
clause, the synonym must resolve to a table or a view owned by the common user issuing the statement.
但是为啥SYSDBA身份登陆就可以查询呢?
因为SYSDBA拥有至高无上的权利。The SYSDBA
system privilege is for fully empowered database administrators.
版权声明:本文为博主原创文章,未经博主允许不得转载。
12c cdb_properties
- 上一篇:Centos 7修改主机名
- 下一篇:DG备库启动报错ORA-38760