1 回答

TA貢獻1827條經(jīng)驗 獲得超8個贊
在實際項目中常常需要做接口提供給其他平臺使用,需要給調用者提供Oracle數(shù)據(jù)庫用戶,此用戶可能只能訪問我方生產(chǎn)庫中的某幾張表,而且只能查詢不能增刪改,這就需要我們從Oracle數(shù)據(jù)庫中給接口設置相應的權限,具體如下:
假設我方用戶為scott,我們給第三方用戶建立的接口用戶為scott_read,我們開放給第三方用戶的表為student表。
1.使用system用戶登錄:sqlplus system/password@orcl。
2.創(chuàng)建scott_read用戶:create user scott_read(用戶名) identified by tiger(密碼)。
3.將connect和resource權限賦給scott_read用戶:grant connect,resource to scott_read。
注意:此處一定注意不要將dba權限賦給scott_read,否則此用戶可以操作我們數(shù)據(jù)庫的任何東西,這是大忌。
4.將scott的student表查詢權限賦給scott_read用戶:grant select on scott.student(表或視圖名) to scott_read。
5.創(chuàng)建同義詞:create or replace synonym scott_read.student for scott.student。
至此,scott_read用戶可以直接查詢student表中的所有數(shù)據(jù),并且不會給我們的數(shù)據(jù)庫造成任何影響。
- 1 回答
- 0 關注
- 562 瀏覽
添加回答
舉報