PostgreSQL 8.2.3 婺桺桺懼
劯锔媆锔媆誕嬉誕

SET ROLE

劉䓄

SET ROLE -- 螆䘞嘷嬉嚔臺䔇嘷嬉䫘潙湺臖严

臺濘

SET [ SESSION | LOCAL ] ROLE rolename
SET [ SESSION | LOCAL ] ROLE NONE
RESET ROLE

柟誄

認溇变傴儖嘷嬉嚔臺䔇嘷嬉䫘潙湺臖婺 rolename 㔗蓐謾劉埇傖喍潊臘臖严潡蔙滇庖严婾桺橸㔗婘 SET ROLE 幋劯SQL 变傴䔇溄鍊演昖儌喘償嘷彺䍂嘘䔇䫘潙滇溴变傴毺垔䔇䫘潙闼湙㔗

嘷嬉嚔臺䔇䫘潙媙釂滇毺垔䔇 rolename 蓐謾䔇潊叻㔗嘖轙亓䫘潙埇傖锬拷傂嘘蓐謾㔗

SESSIONLOCAL 媞閄臉䔇嘩䫘启捞锔䔇 SET 变傴婔湙㔗

NONERESET 嘵嚟麉䘞嘷嬉䫘潙湺臖婺嘷嬉嚔臺䫘潙湺臖严㔗傂嘘䫘潙鄘埇傖欓臯認䓉嘵嚟㔗

濘懟

嘪䫘認溇变傴垄埇脘嚔嵂媹婔婻䫘潙䔇溄鍊幘埇脘嚔鍊彽婔婻䫘潙䔇溄鍊㔗套悩嚔臺䫘潙䔇蓐謾橬 INHERITS 匂攓闼幽垄躻媘拖橬垄脘 SET ROLE 埻潊䔇蓐謾䔇欔橬溄鍊婘認䓉愙喕婋SET ROLE 垂鍙婪滇役鍴庖欔橬䕘毖蕋庽嚔臺䫘潙䔇溄鍊傖埪垄䔇欔匂蓐謾䔇溄鍊埻嬷婋毺垔蓐謾䔇溄鍊㔗埥婔桹麵套悩嚔臺䫘潙䔇蓐謾橬 NOINHERITS 匂攓SET ROLE 役鍴䕘毖蕋庽嚔臺䫘潙䔇溄鍊蔯诙埡毺垔蓐謾䔇溄鍊㔗

垂鍙婪套悩婔婻轙亓䫘潙 SET ROLE 婺婔婻麂轙亓䫘潙垄嚔崌寂噽轙亓䫘潙溄鍊㔗

SET ROLE 橬启 SET SESSION AUTHORIZATION 䌂嚚䔇昽悩嘖滇噽婺潬埪䔇溄鍊演昖橬寺彆㔗誻橬SET SESSION AUTHORIZATION 彴桺橬傔幽蓐謾埇傖䫘庯䘉劯䔇 SET ROLE 变傴蔯䫘 SET ROLE 幽婉媞櫹䘉劯䔇 SET ROLE 埇傖螆䘞䔇蓐謾镖㔗

冋床

SELECT SESSION_USER, CURRENT_USER;

 session_user | current_user 
--------------+--------------
 peter        | peter

SET ROLE 'paul';

SELECT SESSION_USER, CURRENT_USER;

 session_user | current_user 
--------------+--------------
 peter        | paul

噚垹攓

PostgreSQL 噕螩湺臖严臺濘("rolename")蔯 SQL 湺庖襕挗蓐謾劉庖喍潊庖严婾桺橸㔗SQL 幽婉噕螩婘庋媇麯麵欓臯認溇变傴PostgreSQL 幽橻啔溴鍊彽啹婺澇橬䊖䫌鍊彽㔗SESSIONLOCAL 媞閄臉滇 PostgreSQL 䔇欷匘誻橬 RESET 臺濘幘婔湙㔗

埽蓕

SET SESSION AUTHORIZATION

劯锔饡釕嬉誕
SET CONSTRAINTS婪婔亓SET SESSION AUTHORIZATION