CREATE DOMAIN name [ AS ] data_type [ DEFAULT expression ] [ constraint [ ... ] ] 認麯 constraint 滇 [ CONSTRAINT constraint_name ] { NOT NULL | NULL | CHECK (expression) }
CREATE DOMAIN 录傺婔婻桄䔇昄扞嘘㔗嘘婘橸蘘婪滇婔婻婥橬埇锬亥溘䔇昄扞䌂傋(鍊彽噕螩䔇埡唚评啘)㔗垔幬嘘䔇䫘潙潊婺噽欔橬蔙㔗
套悩䂍庺婔婻昇嚟劉䓄(懫套 CREATE DOMAIN myschema.mydomain ...)闼幽臖嘘滇婘毺垔䔇昇嚟婺录傺䔇㔗劥彍垄嚔婘嘷嬉昇嚟婺录傺㔗嘘劉庖媙驔婘噽欔婘昇嚟婺䔇䯄橬䌂傋启嘘婺嫇婔㔗
嘘埇傖冪庯檪婉劯臘幋閘䔇噸噌嘘檘埡彄婔婻啺垔嘉䘞誕臯䂘檴㔗懫套婔婻䫕床闞傽婄应庖枕埇脘婘崔婻臘婺嘪䫘欔橬䔇鄘滇劯湙䔇匂攓㔗埇傖垔幬幽嘪䫘婔婻嘘蔯婉滇彖彆螆䘞懟婻臘䔇亥溘㔗
襕录傺䔇嘘劉庖(埇傖橬昇嚟媞閄)
嘘䔇婋北昄扞䌂傋㔗垄埇傖寙劆昄䂇臘滯严㔗
DEFAULT 床埖婺嘘昄扞䌂傋䔇庖枕弄滯婔婻䚺䩕唚㔗臖唚滇傂嘘婉劆埻麟䔇臘膆嚟(嘖婉噕螩床昖臵)㔗䚺䩕臘膆嚟䔇昄扞䌂傋媙驔对陉嘘䔇昄扞䌂傋㔗套悩澇橬弄滯䚺䩕唚闼幽䚺䩕唚儌滇 NULL 㔗
䚺䩕臘膆嚟儖䫘庯傂嘘䩕䘖臖庖枕唚䔇某噖淉嘩㔗套悩婺䬹垔䔇庖枕弄滯庖䚺䩕唚闼幽垄襖䕡傂嘘启臖嘘䕩噿蕫䔇䚺䩕唚㔗䇽劯嘘䔇䚺䩕襖䕡傂嘘婯婋北昄扞䌂傋䕩噿䔇䚺䩕㔗
婔婻亥溘䔇埇锬劉䓄㔗套悩澇橬弄滯係䂘儖躻媘䫘潊婔婻劉庖㔗
認婻嘘䔇昄唚婉噕螩婺 NULL
認婻嘘䔇昄唚噕螩婺 NULL 㔗認滇䚺䩕㔗
認婻床埖埻滇䫘庯启麂湺庖䔇 SQL 昄扞康噚垹䫘㔗婉傺螞婘桄䔇庫䫘婺嘪䫘垄㔗
CHECK 床埖弄滯嘘䔇昄唚媙釂悇轿䔇垯昘攓亥溘潡敋臘㔗懟婻亥溘媙釂滇婔婻䫘潊婄儫䂷悩䔇臘膆嚟㔗垄庫臖嘪䫘噿髞庖 VALUE 準嚘䫘赆敋臘䔇昄唚㔗
䕞嬉CHECK 臘膆嚟婉脘寙劆床昖臵幘婉脘嚘䫘鍴 VALUE 幋崡䔇埻麟㔗
認婻冋床录傺庖 us_postal_code 昄扞䌂傋幽婫婘婔婻臘垔幬婺嘪䫘庖臖䌂傋㔗嘪䫘庖婔婻溼彍臘膆嚟敋臘傖媺臕認底昄唚䩋蕙準償婔婻䆯啘䔇闞櫪䚡乕㔗
CREATE DOMAIN us_postal_code AS TEXT CHECK( VALUE ~ '^\\d{5}$' OR VALUE ~ '^\\d{5}-\\d{4}$' ); CREATE TABLE us_snail_addy ( address_id SERIAL PRIMARY KEY, street1 TEXT NOT NULL, street2 TEXT, street3 TEXT, city TEXT NOT NULL, postal us_postal_code NOT NULL );