This patch adds an example to the CREATE DOMAIN docs.
authorBruce Momjian
Sun, 8 Aug 2004 01:49:30 +0000 (01:49 +0000)
committerBruce Momjian
Sun, 8 Aug 2004 01:49:30 +0000 (01:49 +0000)
David Fetter

doc/src/sgml/ref/create_domain.sgml

index 7f66816ead4cd2b7048863ac359854c115562f6a..7cf6b4de3856d9f4218d14eb210ea047fb66365a 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -160,11 +160,25 @@ where constraint is:
   Examples
 
   
-   This example creates the country_code data type and then uses the
-   type in a table definition:
+   This example creates the us_postal_code data type and
+    then uses the type in a table definition:
+
 
-CREATE DOMAIN country_code char(2) NOT NULL;
-CREATE TABLE countrylist (id integer, country country_code);
+CREATE DOMAIN us_postal_code AS TEXT
+NOT NULL
+CHECK(
+   VALUE ~ $pc$^\d{5}$$pc$
+OR VALUE ~ $pc$^\d{5}-\d{4}$$pc$
+);
+
+CREATE TABLE us_snail_addy (
+  address_id SERIAL NOT NULL PRIMARY KEY
+, street1 TEXT NOT NULL
+, street2 TEXT
+, street3 TEXT
+, city TEXT NOT NULL
+, postal us_postal_code
+);