CREATE SCHEMA schemaname [ AUTHORIZATION username ] [ schema_element [ ... ] ] CREATE SCHEMA AUTHORIZATION username [ schema_element [ ... ] ]
CREATE SCHEMA 婘嘷嬉昄扞康麯膷噖婔婻桄昇嚟㔗臖昇嚟劉儖婘嘷嬉昄扞康麯䯄庻䔇欔橬昇嚟劉婺嫇婔㔗
昇嚟垂鍙婪滇婔婻劉庖䷺閘垄寙劆变劉凹茇(臘㔕昄扞䌂傋㔕庘昄㔕淉嘩严)認底劉庖埇傖启噽垄昇嚟麯庻婘䔇噽垄凹茇麉劉㔗变劉凹茇襕幽滇锔誺䫘昇嚟劉嘩婺嬉䚔"媞閄"誕臯螪閞襕幽滇锔誺螆䘞婔婻抩䘵虇冇寙劆欔驔襕䔇昇嚟㔗婔溇婥五方媞閄凹茇劉䔇 CREATE 变傴鄘滇婘嘷嬉昇嚟婺录傺䔇(婘抩䘵虇冇橔嬉麵䔇昇嚟埇傖䫘 current_schema
庘昄準彴桺)㔗
埥崡CREATE SCHEMA 埇傖寙拸婘桄昇嚟婺录傺凹茇䔇床变傴㔗認底床变傴启闼底婘录傺垯昇嚟劯埏庺䔇变傴澇橬傂嘘寺彆埻婉誺滇套悩嘪䫘庖 AUTHORIZATION 床埖闼幽欔橬录傺䔇凹茇鄘儖赆臖䫘潙拖橬㔗
襕录傺䔇昇嚟劉庖㔗套悩䩕䘖彍嘪䫘䫘潙劉嘩婺昇嚟劉㔗認婻劉庖婉脘傖 pg_ 嚔崘啹婺認湙䔇劉庖媺䘍䂍係䂘昇嚟嘪䫘㔗
儖拖橬臖昇嚟䔇䫘潙劉㔗套悩䩕䘖䚺䩕婺欓臯臖变傴䔇䫘潙劉㔗埻橬轙亓䫘潙欉脘录傺婉匂庯躻噌䔇昇嚟㔗
婔婻 SQL 臺埖垔幬婔婻襕婘昇嚟麯录傺䔇凹茇㔗䕞嬉埻橬 CREATE TABLE, CREATE VIEW, CREATE INDEX, CREATE SEQUENCE, CREATE TRIGGER, GRANT 滇埇傖毖埖䔇床埖㔗噽垄䌂傋䔇凹茇埇傖婘录傺垯昇嚟幋劯䔇䋸䆋变傴麯录傺㔗
录傺婔婻昇嚟
CREATE SCHEMA myschema;
婺䫘潙 joe 录傺昇嚟昇嚟劉幘埆 joe
CREATE SCHEMA AUTHORIZATION joe;
录傺婔婻昇嚟幽婫婘麯麵录傺婔婻臘
CREATE SCHEMA hollywood CREATE TABLE films (title text, release date, awards text[]) CREATE VIEW winners AS SELECT title, release FROM films WHERE awards IS NOT NULL;
臙濘懟婪麵䋸䆋䔇床变傴婉滇䫌彖埙䂷儆䔇㔗
婋麵䔇变傴滇垂䯄劯湙䂷悩䔇京昽臺埖
CREATE SCHEMA hollywood; CREATE TABLE hollywood.films (title text, release date, awards text[]); CREATE VIEW hollywood.winners AS SELECT title, release FROM hollywood.films WHERE awards IS NOT NULL;