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

SET SESSION AUTHORIZATION

劉䓄

SET SESSION AUTHORIZATION -- 婺嘷嬉嚔臺螆䘞嚔臺䫘潙湺臖严启嘷嬉䫘潙湺臖严

臺濘

SET [ SESSION | LOCAL ] SESSION AUTHORIZATION username
SET [ SESSION | LOCAL ] SESSION AUTHORIZATION DEFAULT
RESET SESSION AUTHORIZATION

柟誄

認溇变傴檪嘷嬉嚔臺䯇嵄麯䔇嚔臺䫘潙湺臖启嘷嬉䫘潙湺臖鄘螆䘞婺 username 㔗認婻䫘潙劉埇傖喍潊婔婻湺臖严潡蔙婔婻庖严婾桺橸㔗嘪䫘認婻变傴埇傖婘施埻潊婔婻麂䬹溄䫘潙䘉劯喉彺扵啂轙亓䫘潙㔗

嚔臺䫘潙湺臖严婔嚔哋螆䘞婺(埇脘䂟誺螴臕䔇)垵潙䆇柊冕䔇䫘潙劉㔗嘷嬉䫘潙湺臖严锔婩京庯嚔臺䫘潙湺臖严嘖滇埇脘婘"setuid"䔇䯇嵄麯潡蔙䌂嚚䔇橺彽麯婘施櫹埻㔗幘埇傖䫘 SET ROLE 準媞櫹㔗嘷嬉䫘潙䔇躆傘启溄鍊演昖橬噿㔗

埻橬婘彺哋嚔臺䫘潙(噾螴臕䫘潙)橬轙亓䫘潙溄鍊䔇施唍嚔臺䫘潙湺臖严欉脘櫹埻㔗劥彍埻橬婘毺垔庖赆螴臕䔇䫘潙劉䔇愙喕婋係䂘欉毖埖臖变傴㔗

The SESSIONLOCAL 媞閄臉启捞锔 SET 变傴麯䔇嘩䫘䕩劯㔗

The DEFAULTRESET 嘵嚟麉䘞嚔臺启嘷嬉䫘潙湺臖严婺彺哋螴臕䔇䫘潙劉㔗認底嘵嚟埇傖婺傂嘘䫘潙欓臯㔗

冋床

SELECT SESSION_USER, CURRENT_USER;

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

SET SESSION AUTHORIZATION 'paul';

SELECT SESSION_USER, CURRENT_USER;

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

噚垹攓

SQL 湺庖噕螩婔底噽垄䔇臘膆嚟庺䯄婘桺橸 username 䔇嘉䘞婪婉誺認婻婩薪垂鍙婪幽婉麉襕㔗PostgreSQL 噕螩湺臖严臺濘("username")蔯 SQL 婉噕螩㔗SQL 婉噕螩婘婔婻庋媇䔇誺䘋婺䫘認溇变傴PostgreSQL 澇橬認婻鍊彽啹婺澇橬傔幽䊖䫌婉噕螩認湙䫘㔗SESSIONLOCAL 滇 PostgreSQL 欷匘RESET 臺濘幘滇㔗

湺庖檪欓臯認溇变傴欔驔襕䔇溄鍊䘍䂍噙嘷垂䯄準垔幬㔗

埽蓕

SET ROLE

劯锔饡釕嬉誕
SET ROLE婪婔亓SET TRANSACTION