山西快3网投app—官方网址22270.COM鈥擯ostgreSQL PRIVILEGES锛堟潈闄愶級

鏃犺浣曟椂鍒涘缓鏁版嵁搴撳璞★紝閮戒細涓哄叾鍒嗛厤涓涓墍鏈夎咃紝鎵鏈夎呴氬父鏄墽琛 create 璇彞鐨勪汉銆

山西快3网投app—官方网址22270.COM瀵逛簬澶у鏁扮被鍨嬬殑瀵硅薄锛屽垵濮嬬姸鎬佹槸鍙湁鎵鏈夎(鎴栬秴绾х敤鎴)鎵嶈兘淇敼鎴栧垹闄ゅ璞°傝鍏佽鍏朵粬瑙掕壊鎴栫敤鎴蜂娇鐢ㄥ畠锛屽繀椤讳负璇ョ敤鎴疯缃潈闄愩

鍦 山西快3网投app—官方网址22270.COM鈥擯ostgreSQL 涓紝鏉冮檺鍒嗕负浠ヤ笅鍑犵锛

  • SELECT
  • INSERT
  • UPDATE
  • DELETE
  • TRUNCATE
  • REFERENCES
  • TRIGGER
  • CREATE
  • CONNECT
  • TEMPORARY
  • EXECUTE
  • USAGE

鏍规嵁瀵硅薄鐨勭被鍨(琛ㄣ佸嚱鏁扮瓑)锛屽皢鎸囧畾鏉冮檺搴旂敤浜庤瀵硅薄銆

瑕佸悜鐢ㄦ埛鍒嗛厤鏉冮檺锛屽彲浠ヤ娇鐢 GRANT 鍛戒护銆

GRANT 璇硶

GRANT 鍛戒护鐨勫熀鏈娉曞涓嬶細

GRANT privilege [, ...]
ON object [, ...]
TO { PUBLIC | GROUP group | username }
  • privilege 鈭 鍊煎彲浠ヤ负锛歋ELECT锛孖NSERT锛孶PDATE锛孌ELETE锛 RULE锛孉LL銆
  • object 鈭 瑕佹巿浜堣闂潈闄愮殑瀵硅薄鍚嶇О銆傚彲鑳界殑瀵硅薄鏈夛細 table锛 view锛宻equence銆
  • 山西快3网投app—官方网址22270.COMPUBLIC 鈭 琛ㄧず鎵鏈夌敤鎴枫
  • GROUP group 鈭 涓虹敤鎴风粍鎺堜簣鏉冮檺銆
  • username 鈭 瑕佹巿浜堟潈闄愮殑鐢ㄦ埛鍚嶃山西快3网投app—官方网址22270.COMPUBLIC 鏄唬琛ㄦ墍鏈夌敤鎴风殑绠鐭舰寮忋

鍙﹀锛屾垜浠彲浠ヤ娇鐢 REVOKE 鍛戒护鍙栨秷鏉冮檺锛孯EVOKE 璇硶锛

REVOKE privilege [, ...]
ON object [, ...]
FROM { PUBLIC | GROUP groupname | username }

瀹炰緥

涓轰簡鐞嗚В鏉冮檺锛屽垱寤轰竴涓敤鎴凤細

runoobdb=# CREATE USER runoob WITH PASSWORD 'password';
CREATE ROLE

淇℃伅 CREATE ROLE 琛ㄧず鍒涘缓浜嗕竴涓敤鎴 "runoob"銆

瀹炰緥

鍒涘缓 COMPANY 琛紙涓嬭浇 COMPANY SQL 鏂囦欢 锛夛紝鏁版嵁鍐呭濡備笅锛

runoobdb# select * from COMPANY;
 id | name  | age | address   | salary
----+-------+-----+-----------+--------
  1 | Paul  |  32 | California|  20000
  2 | Allen |  25 | Texas     |  15000
  3 | Teddy |  23 | Norway    |  20000
  4 | Mark  |  25 | Rich-Mond |  65000
  5 | David |  27 | Texas     |  85000
  6 | Kim   |  22 | South-Hall|  45000
  7 | James |  24 | Houston   |  10000
(7 rows)

鐜板湪缁欑敤鎴 "runoob" 鍒嗛厤鏉冮檺锛

runoobdb=# GRANT ALL ON COMPANY TO runoob;
GRANT

淇℃伅 GRANT 琛ㄧず鎵鏈夋潈闄愬凡缁忓垎閰嶇粰浜 "runoob"銆

涓嬮潰鎾ら攢鐢ㄦ埛 "runoob" 鐨勬潈闄愶細

runoobdb=# REVOKE ALL ON COMPANY FROM runoob;
REVOKE

淇℃伅 REVOKE 琛ㄧず宸茬粡灏嗙敤鎴风殑鏉冮檺鎾ら攢銆

浣犱篃鍙互鍒犻櫎鐢ㄦ埛锛

runoobdb=# DROP USER runoob;
DROP ROLE

山西快3网投app—官方网址22270.COM淇℃伅 DROP ROLE 琛ㄧず鐢ㄦ埛 "runoob" 宸茬粡浠庢暟鎹簱涓垹闄ゃ