䯄婘嘉䘞饡釕 > 昄扞康 > PostgreSQL > PostgreSQL溄鍊

PostgreSQL溄鍊

準溊寘录桺䆹    䫌 悕垵幥 敘桄䬽橸    敟蓽庺渇

懟嘷婘昄扞康婺录傺婔婻凹茇欔橬蔙埇傖彖陉垄螪閞溄鍊㔗欔橬蔙锔婩滇欓臯录傺臺埖㔗凹庯崓崔昄䌂傋䔇凹茇彺哋䪽攕滇埻橬凹欔橬蔙潡轙亓䫘潙埇傖媞櫹潡役鍴䔇凹茇㔗婺庖螷噽傡蓐謾潡䫘潙嘪䫘垄䬹溄潡溄鍊媙釂滇䊖欔嘷䇽㔗

gitbook.net

婘PostgreSQL溄鍊婉劯滇 www.gitbook.net

  • SELECT, gitbook.net

  • INSERT, gitbook.net

  • UPDATE,

    www.gitbook.net

  • DELETE,

    gitbook.net

  • TRUNCATE, www.gitbook.net

  • REFERENCES, gitbook.net

  • TRIGGER,

    gitbook.net

  • CREATE,

    www.gitbook.net

  • CONNECT, www.gitbook.net

  • TEMPORARY, www.gitbook.net

  • EXECUTE, and

    gitbook.net

  • USAGE gitbook.net

湹扞婉劯䔇凹茇臘庘昄京庫䫘彄凹茇䔇溄鍊㔗婺庖䂍䫘潙彖陉溄鍊嘪䫘GRANT变傴㔗

www.gitbook.net

毽溄臺濘

GRANT变傴䔇嘺橸臺濘套婋 www.gitbook.net

GRANT privilege [, ...]
ON object [, ...]
TO { PUBLIC | GROUP group | username } www.gitbook.net 
  • privilege 埇脘䔇唚橬: SELECT, INSERT, UPDATE, DELETE, RULE, ALL. www.gitbook.net

  • object: 劉䓄凹茇毽庽螪閞溄鍊㔗埇脘䔇凹茇滇臘蓖商废彖

    www.gitbook.net

  • PUBLIC A 䚷喍嘵嚟傼臘欔橬䫘潙㔗

    gitbook.net

  • GROUP group: 䂇毽庽溄鍊㔗 gitbook.net

  • username: 毽庽溄鍊䔇䫘潙䔇劉䓄. PUBLIC 滇婔婻䞔䘺䔇嘵嚟傼臘欔橬䫘潙㔗 gitbook.net

溄鍊埇傖嘪䫘REVOKE变傴搴體㔗

gitbook.net

REVOKE䔇臺濘

REVOKE变傴䔇嘺橸臺濘套婋

www.gitbook.net

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

www.gitbook.net

  • privilege 埇脘䔇唚橬: SELECT, INSERT, UPDATE, DELETE, RULE, ALL. gitbook.net

  • object: 劉䓄凹茇毽庽螪閞溄鍊㔗埇脘䔇凹茇滇臘蓖商废彖 gitbook.net

  • PUBLIC 䞔䘺嘵嚟傼臘欔橬䫘潙. gitbook.net

  • GROUP group: 䂇毽庽溄鍊㔗

    www.gitbook.net

  • username: 毽庽溄鍊䔇䫘潙䔇劉䓄. PUBLIC滇婔婻䞔䘺䔇嘵嚟傼臘欔橬䫘潙㔗

    www.gitbook.net

垂冋

襕庖蓼溄鍊螷潏傸噽录傺婔婻USER套婋

gitbook.net

testdb=# CREATE USER manisha WITH PASSWORD 'password';
CREATE ROLE gitbook.net 

潽敇CREATE ROLE臘滯USER“manisha”录傺㔗

gitbook.net

蔄荏臘COMPANY 橬套婋螄嘘 www.gitbook.net

testdb# 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)
 www.gitbook.net 

毖婋準螷潏傸䔇欔橬溄鍊毽庽婔婻臘噸埩䔇䔇䫘潙“manisha”套婋 www.gitbook.net

testdb=# GRANT ALL ON COMPANY TO manisha;
GRANT 
www.gitbook.net

GRANT潽敇臘滯欔橬䔇溄鍊赆彖陉䂍USER㔗

gitbook.net

毖婋準螷潏傸搴體溄鍊傯USER婺䔇“MANISHA”套婋

gitbook.net

testdb=# REVOKE ALL ON COMPANY FROM manisha;
REVOKE 

gitbook.net

REVOKE潽敇臘滯欔橬䔇溄鍊赆搴體䔇USER㔗 www.gitbook.net

䫔躿埇傖役鍴䫘潙套婋 www.gitbook.net

testdb=# DROP USER manisha;
DROP ROLE www.gitbook.net 

潽敇DROP ROLE臘䴺䫘潙MANISHA滇傯昄扞康婺役鍴㔗

gitbook.net

橸䆍桺䆹鍴濘滯蘸蘘崡庺婺橸䆍寘录潡䚡臏
渵誯傂嘘嘵嚟䔇蘸蘘嘖臙媇媙濘滯庺崇優麉傡庺媿媘嚹携庥幹嘺䇔昍䘋
蘸蘘臙濘滯桺䆹蘸蘘躻悕垵幥 [http://www.gitbook.net]
橸桺湺鵻PostgreSQL溄鍊
蘸蘘臙媺䘍寘桺鷆毖:http://www.gitbook.net/html/postgresql/2013/080782.html
婪婔䇺PostgreSQL躻媘嵂媹      婋婔䇺PostgreSQL斖橘施閘DATE/TIME