最近2018中文字幕在日韩欧美国产成人片_国产日韩精品一区二区在线_在线观看成年美女黄网色视频_国产精品一区三区五区_国产精彩刺激乱对白_看黄色黄大色黄片免费_人人超碰自拍cao_国产高清av在线_亚洲精品电影av_日韩美女尤物视频网站

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
postgresql數(shù)據(jù)庫刪除用戶的方法-創(chuàng)新互聯(lián)

創(chuàng)新互聯(lián)www.cdcxhl.cn八線動態(tài)BGP香港云服務(wù)器提供商,新人活動買多久送多久,劃算不套路!

創(chuàng)新互聯(lián)建站主要從事成都網(wǎng)站建設(shè)、成都網(wǎng)站制作、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)庫爾勒,十余年網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):028-86922220

這篇文章將為大家詳細講解有關(guān)postgresql數(shù)據(jù)庫刪除用戶的方法,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

將介紹PostgreSQL下如何快速刪除一個用戶(role)。

一般情況下直接執(zhí)行 drop role xxx; 就可以把這個用戶刪除。但是很多時候會因為用戶有依賴而報錯。

推薦:postgresql教程

權(quán)限依賴

postgres=# create role test with login;
CREATE ROLE
postgres=# grant all on database postgres to test;
GRANT
postgres=# drop role test;
ERROR:  role "test" cannot be dropped because some objects depend on it
DETAIL:  privileges for database postgres

可以看出,因為我們把數(shù)據(jù)庫postgres 的權(quán)限賦予了test 用戶,所以直接刪除的時候會報錯。面對這種情況,我們需要先將role 的權(quán)限

所有的權(quán)限全部revoke 掉,如下:

postgres=# revoke all on database postgres from test;
REVOKE
postgres=# drop role test;
DROP ROLE

注意:需要把該用戶在所有數(shù)據(jù)庫具有權(quán)限的所有數(shù)據(jù)庫對象的(表,視圖,SEQUENCE)權(quán)限全部回收,才能刪除該用戶。

對象依賴

postgres=# create role test with login;
CREATE ROLE
postgres=# \c - test
You are now connected to database "postgres" as user "test".
postgres=> create table test (id int);
CREATE TABLE
postgres=# \c - postgres
You are now connected to database "postgres" as user "postgres".
postgres=# drop role test;
ERROR:  role "test" cannot be dropped because some objects depend on it
DETAIL:  owner of table test

可以看出,因為test 用戶是test 表的owner,所以刪除的時候報錯owner of table test。如果不需要保留該對象,則需要先把該依賴對象

刪除。如果需要保留該對象,則應該在刪除之前先把owner 賦予別人,如下:

postgres=# alter table test OWNER  TO postgres;
ALTER TABLE
postgres=# drop role test;
DROP ROLE

注意:需要把該用戶在所有數(shù)據(jù)庫具有owner 權(quán)限的所有數(shù)據(jù)庫對象(表,視圖,SEQUENCE)刪除或者執(zhí)行alter xx owner to,才能

刪除該用戶。

關(guān)于postgresql數(shù)據(jù)庫刪除用戶的方法就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。


網(wǎng)頁名稱:postgresql數(shù)據(jù)庫刪除用戶的方法-創(chuàng)新互聯(lián)
鏈接URL:http://fisionsoft.com.cn/article/dhhcge.html