對Oracle View授權和where查詢需要注意的地方
授權需要注意:
SQL> create user test identified by test default tablespace userdata temporary tablespace temp;
User created.
SQL> create user test111 identified by test111 default tablespace userdata temporary tablespace temp;
User created.
SQL> create user test222 identified by test222 default tablespace userdata temporary tablespace temp;
User created.
SQL> grant create session,create table,unlimited tablespace to test;
Grant succeeded.
SQL> grant create session,create view to test111;
Grant succeeded.
SQL> grant create session to test222;
Grant succeeded.
SQL> connect test/test
Connected.
SQL> create table xiaoyang(name varchar2(20));
Table created.
SQL> insert into xiaoyang values('aaaa');
1 row created.
SQL> commit;
Commit complete.
SQL> grant select on xiaoyang to test111;
Grant succeeded.
SQL> connect test111/test111
Connected.
SQL> create view xiaoyang as select * from test.xiaoyang;
View created.
SQL> select * from test111.xiaoyang;
NAME
----------
aaaa
SQL> grant select on test111.xiaoyang to test222;
grant select on test111.xiaoyang to test222
*
ERROR at line 1:
ORA-01720: grant option does not exist for 'TEST.XIAOYANG'
SQL> connect test/test
Connected.
SQL> grant select on xiaoyang to test222;
Grant succeeded.
SQL> connect test111/test111
Connected.
--即使在上面已經將select on xiaoyang的許可權賦予了test222,這裡依然會報錯。
SQL> grant select on test111.xiaoyang to test222;
grant select on test111.xiaoyang to test222
*
ERROR at line 1:
ORA-01720: grant option does not exist for 'TEST.XIAOYANG'
SQL> connect test/test
Connected.
--唯有將test.xiaoyang的with grant option賦予test111,然後test111將檢視xiaoyang賦予test222才不會報錯。
SQL> grant select on xiaoyang to test111 with grant option;
Grant succeeded.
SQL> connect test111/test111;
Connected.
SQL> grant select on test111.xiaoyang to test222;
Grant succeeded.
SQL> connect test222/test222
Connected.
SQL> select * from test111.xiaoyang;
NAME
----------
aaaa
對檢視新增WHERE條件需要注意:
[oracle@blliu ~]$ sqlplus system/manager
SQL*Plus: Release 10.2.0.4.0 - Production on Mon Jan 25 20:37:00 2010
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create table test as select * from dba_segments;
Table created.
SQL> create index idx_sys_test_pk on test(segment_name);
Index created.
SQL> set autotrace trace explain;
SQL> set linesize 200
SQL> select owner,segment_name,segment_type from test where segment_name='TEST';
Execution Plan
----------------------------------------------------------
Plan hash value: 1310262519
-----------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 70 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| TEST | 1 | 70 | 2 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | IDX_SYS_TEST_PK | 1 | | 1 (0)| 00:00:01 |
-----------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("SEGMENT_NAME"='TEST')
Note
-----
- dynamic sampling used for this statement
SQL> set autotrace off
SQL> create view v_test1 as select owner,segment_name,segment_type from test ;
View created.
SQL> create view v_test2 as select owner,rtrim(ltrim(segment_name)) segment_name,segment_type from test;
View created.
SQL> set autotrace trace explain;
SQL> select * from v_test1 where segment_name='TEST';
Execution Plan
----------------------------------------------------------
Plan hash value: 1310262519
-----------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 70 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| TEST | 1 | 70 | 2 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | IDX_SYS_TEST_PK | 1 | | 1 (0)| 00:00:01 |
-----------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("SEGMENT_NAME"='TEST')
Note
-----
- dynamic sampling used for this statement
SQL> select * from v_test2 where segment_name='TEST';
Execution Plan
----------------------------------------------------------
Plan hash value: 1357081020
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 70 | 9 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| TEST | 1 | 70 | 9 (0)| 00:00:01 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(RTRIM(LTRIM("SEGMENT_NAME"))='TEST')
Note
-----
- dynamic sampling used for this statement
SQL>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23135684/viewspace-624740/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle 跨庫查詢的授權方式Oracle
- oracle over()的使用和需要特別注意的地方Oracle
- 使用Context建立一個View需要注意的地方ContextView
- oracle 11.2.0.3 版本 vote盤需要注意的地方Oracle
- 查詢資料庫授權以及授權到期的處理方法資料庫
- Laravel 的 where or 查詢Laravel
- oracle顯式授權和隱式授權Oracle
- delete與delete[]需要注意的地方delete
- Oracle授權A使用者查詢B使用者的所有表Oracle
- 行內元素和塊計元素需要注意的地方
- 備忘:laravel 對查詢結果集可以迴圈where查詢Laravel
- margin-top使用需要注意的地方
- /etc/fstab檔案需要注意的地方
- 甲骨文嚴查Java授權 、 openJDK 注意避坑JavaJDK
- Nhibernate 對view 查詢的幾種方法View
- js switch語句需要特別注意的地方JS
- link流程 建立時需要注意的地方
- 26個提升java效能需要注意的地方Java
- Struts中上傳檔案需要注意的地方
- MongoDB查詢(陣列、內嵌文件和$where)MongoDB陣列
- thinkphp6----where查詢PHP
- MySQL 語句大全:建立、授權、查詢、修改等MySql
- oracle授權Oracle
- springMVC的@ResponseBody、@RequestBody使用需要注意的地方SpringMVC
- 用decode和nvl處理null值時需要注意的地方Null
- 對列授權
- 【Redis】redis-cluster需要注意的幾個地方Redis
- javascript原型繼承constructor需要注意的地方JavaScript原型繼承Struct
- javascript變數宣告需要注意的一個地方JavaScript變數
- 在PHP中使用類可能需要注意的地方PHP
- java打包exe程式需要注意的幾個地方Java
- Oracle 查詢許可權角色Oracle
- 需要的查詢
- Oracle建立使用者和授權Oracle
- Oracle建立使用者並給使用者授權查詢指定表或檢視的許可權Oracle
- oracle改了表名後,不需要去更改授權Oracle
- 隱藏引數查詢和dictionary viewView
- Oracle 查詢轉換-02 View MergingOracleView