File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change 11<!--
2- $PostgreSQL: pgsql/doc/src/sgml/ref/create_domain.sgml,v 1.17 2003/11/29 19:51:38 pgsql Exp $
2+ $PostgreSQL: pgsql/doc/src/sgml/ref/create_domain.sgml,v 1.18 2004/08/08 01:49:30 momjian Exp $
33PostgreSQL documentation
44-->
55
@@ -160,11 +160,25 @@ where <replaceable class="PARAMETER">constraint</replaceable> is:
160160 <title>Examples</title>
161161
162162 <para>
163- This example creates the <type>country_code</type> data type and then uses the
164- type in a table definition:
163+ This example creates the <type>us_postal_code</type> data type and
164+ then uses the type in a table definition:
165+
165166<programlisting>
166- CREATE DOMAIN country_code char(2) NOT NULL;
167- CREATE TABLE countrylist (id integer, country country_code);
167+ CREATE DOMAIN us_postal_code AS TEXT
168+ NOT NULL
169+ CHECK(
170+ VALUE ~ $pc$^\d{5}$$pc$
171+ OR VALUE ~ $pc$^\d{5}-\d{4}$$pc$
172+ );
173+
174+ CREATE TABLE us_snail_addy (
175+ address_id SERIAL NOT NULL PRIMARY KEY
176+ , street1 TEXT NOT NULL
177+ , street2 TEXT
178+ , street3 TEXT
179+ , city TEXT NOT NULL
180+ , postal us_postal_code
181+ );
168182</programlisting>
169183 </para>
170184 </refsect1>
You can’t perform that action at this time.
0 commit comments