1 回答

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