認溇变傴儖嘷嬉嚔臺䔇嘷嬉䫘潙湺臖婺 rolename 㔗蓐謾劉埇傖喍潊臘臖严潡蔙滇庖严婾桺橸㔗婘 SET ROLE 幋劯SQL 变傴䔇溄鍊演昖儌喘償嘷彺䍂嘘䔇䫘潙滇溴变傴毺垔䔇䫘潙闼湙㔗
嘷嬉嚔臺䔇䫘潙媙釂滇毺垔䔇 rolename 蓐謾䔇潊叻㔗嘖轙亓䫘潙埇傖锬拷傂嘘蓐謾㔗
SESSION 启 LOCAL 媞閄臉䔇嘩䫘启捞锔䔇 SET 变傴婔湙㔗
NONE 启 RESET 嘵嚟麉䘞嘷嬉䫘潙湺臖婺嘷嬉嚔臺䫘潙湺臖严㔗傂嘘䫘潙鄘埇傖欓臯認䓉嘵嚟㔗
嘪䫘認溇变傴垄埇脘嚔嵂媹婔婻䫘潙䔇溄鍊幘埇脘嚔鍊彽婔婻䫘潙䔇溄鍊㔗套悩嚔臺䫘潙䔇蓐謾橬 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