䫌庯 PostgreSQL 蓇彍係䂘凹昖臵䔇麉喍麂彺哋昖臵毺垔䔇噽垄臘/蓖商赆螪閞㔗嘪䫘敘桄蓇彍䔇施唍認埇脘寙拸凹臘䔇喍溄鍊㔗
麉喍蓇彍幽婉拖橬婔婻䋸䆋䔇欔橬蔙㔗噿係(臘潡蓖商)䔇欔橬蔙躻媘潊婺麉喍蓇彍䔇䚺䩕欔橬蔙㔗PostgreSQL 蓇彍係䂘櫹埻䚺䩕䔇螪閞毓彽係䂘䔇䬹攓㔗啹蓇彍蔯嘪䫘䔇噿係婘(蓇彍)麉喍施襕凹垔幬蓇彍欔橬蔙誕臯溄鍊演昖蔯婉滇檔昂蓇彍䔇䫘潙認懟叿五婔婻䫘潙埻驔襕凹傡䔇昖臵麯滯䇞毺垔䔇臘/蓖商拖橬欔驔䔇溄鍊儌埇誕臯淉嘩㔗
冋套昊䫘潙橬婔婻䫕臺埙乕彖臘噽婺婔底滇䓕庺䔇埥崡䔇婔底滇媂噸垴䓻幥驔襕䔇㔗傡埇傖䫘婋麵桹濘悇傺昖臵
CREATE TABLE phone_data (person text, phone text, private boolean); CREATE VIEW phone_number AS SELECT person, phone FROM phone_data WHERE NOT private; GRANT SELECT ON phone_number TO secretary;
鍴庖傡傖崡(誻橬昄扞康轙亓䫘潙)澇橬庺埇傖螪閞 phone_data 臘㔗嘖啹婺 GRANT 䔇寘啹䓻幥埇傖傯 phone_number 蓖商婪誊臯 SELECT 㔗蓇彍係䂘儖檪傯 phone_number 麯䔇 SELECT 麉喍婺傯 phone_data 麯䔇 SELECT 幽儖嵂媹溇傽㔗埻橬 private 溇傽婺啺䔇螄嘘欉埇傖锬庺㔗啹婺䫘潙滇 phone_number 䔇欔橬蔙啹溴幘滇蓇彍䔇欔橬蔙欔傖䯄婘襕演昖傡凹 phone_data 䔇臂螪閞䔇溄鍊蔯認婻昖臵滇赆噕螩䔇㔗劯施幘襕演昖螪閞 phone_number 䔇溄鍊嘖認滇凹婔婻赆搴潽溄鍊䔇䫘潙誕臯演昖䔇欔傖鍴庖䫘潙躻噌启䓻幥崡澇橬庺埇傖嘪䫘垄㔗
溄鍊演昖滇毬蓇彍锊溇誕臯䔇㔗欔傖溴施䔇䓻幥滇嫇婔䔇婔婻埇傖䩋彄噸噌䫕臺埙乕䔇庺㔗嘖䓻幥埇傖螆䆋埥婔婻蓖商幽婫蕋庽臖蓖商噸噌溄鍊㔗認湙傂嘘庺鄘埇傖锔誺䓻幥䔇蓖商䩋彄 phone_number 昄扞㔗䓻幥婉脘啔䔇庋愙滇录傺婔婻䕘毖螪閞 phone_data 䔇蓖商(垂鍙婪傡滇埇傖䔇嘖澇橬傂嘘嘩䫘啹婺懟婻螪閞鄘嚔啹锔婉誺溄鍊演昖蔯赆詵庺庋媇)㔗蔯婫䫘潙冽媆嚔螴臖彄䓻幥嚔櫆庖傡䔇 phone_number 蓖商劯傡誻埇傖搴潽傡䔇螪閞溄鍊㔗認湙欔橬凹䓻幥蓖商䔇螪閞鷸婪儌崌昽庖㔗
橬底庺嚔螴婺認䓉锊溇蓇彍䔇演昖滇婔婻垬噘暟昂嘖庋垂婪婉滇㔗套悩認湙啔婉脘喟昽䓻幥儖媙釂傺䆋婔婻婯 phone_number 橬䕩劯庖枕䔇臘幽婫懟崷拙蘺婔渇昄扞誕寂㔗闼幽認滇傡躻噌䔇昄扞啹蔯埇傖蕋庽噽垄庺螪閞䔇溄媕㔗婔婻 GRANT 懟叿五"潏媇傂嘹"㔗套悩昊婻嘹媇傂䔇庺啔庖婪麵䔇庋愙闼嘹儌臖愿愿滇劥臖 REVOKE 庖㔗
認婻橺彽劯湙埇傖䫘庯敘桄蓇彍㔗婘婪婔䆹䔇冋床麯冋床昄扞康麯䔇臘䔇欔橬蔙埇傖檪 shoelace 蓖商䔇 SELECT, INSERT, UPDATE, DELETE 溄鍊蕋庽噽傡庺㔗嘖凹 shoelace_log 埻橬 SELECT 溄鍊㔗喍斖媖螄嘘䔇蓇彍媘嘩傉䇽埇傖潊媘䔇欓臯㔗幽婫噽垄䫘潙埇傖䩋彄斖媖螄嘘㔗嘖傡婉脘录傺嚻螄嘘蔯婫傡幘婉脘凹䯄橬螄嘘誕臯媞櫹潡役鍴㔗