oracle 如果我们给予特定用户的视图权限,而视图和表不存在,则会自动授予自动应用的表权限

tct7dpnv  于 2023-03-17  发布在  Oracle
关注(0)|答案(1)|浏览(168)

一旦为特定用户的视图提供了权限,它是否会自动为Oracle中视图的基础表给予权限?
与Oracle视图相关

vuv7lop3

vuv7lop31#

否(如pmdba所评论的);这就是它的美妙之处。
我目前以Scott的身份连接:

SQL> show user
USER is "SCOTT"

这是我的table

SQL> select * from emp;

     EMPNO ENAME      JOB              MGR HIREDATE        SAL       COMM     DEPTNO
---------- ---------- --------- ---------- -------- ---------- ---------- ----------
      7369 SMITH      CLERK           7902 17.12.80        840                    20
      7499 ALLEN      SALESMAN        7698 20.02.81       1600        300         30
      7521 WARD       SALESMAN        7698 22.02.81       1250        500         30
      7566 JONES      MANAGER         7839 02.04.81       2975                    20
      7654 MARTIN     SALESMAN        7698 28.09.81       1250       1400         30
      7698 BLAKE      MANAGER         7839 01.05.81       2850                    30
      7782 CLARK      MANAGER         7839 09.06.81       2450                    10
      7788 SCOTT      ANALYST         7566 09.12.82       3000                    20
      7839 KING       PRESIDENT            17.11.81       5000                    10
      7844 TURNER     SALESMAN        7698 08.09.81       1500          0         30
      7876 ADAMS      CLERK           7788 12.01.83       1100                    20
      7900 JAMES      CLERK           7698 03.12.81        950                    30
      7902 FORD       ANALYST         7566 03.12.81       3000                    20
      7934 MILLER     CLERK           7782 23.01.82       1300                    10

14 rows selected.

视图仅从该表中选择列和行的子集:

SQL> create or replace view v_emp as
  2    select ename, job
  3    from emp
  4    where deptno = 10;

View created.

select权限授予其他用户Mike:

SQL> grant select on v_emp to mike;

Grant succeeded.

以Mike身份连接:

SQL> connect mike/pwd@orcl
Connected.

从该视图中进行选择-我只能看到视图返回的内容:

SQL> select * from scott.v_emp;

ENAME      JOB
---------- ---------
CLARK      MANAGER
KING       PRESIDENT
MILLER     CLERK

仅查看视图,我不知道它基于哪个表;我可以这样描述:

SQL> desc scott.v_emp
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ENAME                                              VARCHAR2(10)
 JOB                                                VARCHAR2(9)

我可以在all_objects中看到它:

SQL> select object_name, object_type, created, status
  2  from all_objects
  3  where owner = 'SCOTT'
  4    and object_name = 'V_EMP';

OBJECT_NAME                    OBJECT_TYPE         CREATED  STATUS
------------------------------ ------------------- -------- -------
V_EMP                          VIEW                09.03.23 VALID

SQL>

all_source中没有任何内容:

SQL> select text
  2  from all_source
  3  where owner = 'SCOTT'
  4    and name = 'V_EMP';

no rows selected

好吧,我 * 知道 * 它是emp表,所以-让我们尝试直接从中选择:

SQL> select * from scott.emp;
select * from scott.emp
                    *
ERROR at line 1:
ORA-00942: table or view does not exist

SQL>

不出所料,这行不通。

相关问题