1- <!-- $PostgreSQL: pgsql/doc/src/sgml/ddl.sgml,v 1.38 2005/01/17 01:29:02 tgl Exp $ -->
1+ <!-- $PostgreSQL: pgsql/doc/src/sgml/ddl.sgml,v 1.39 2005/01/22 22:56:35 momjian Exp $ -->
22
33<chapter id="ddl">
44 <title>Data Definition</title>
@@ -275,7 +275,7 @@ CREATE TABLE products (
275275CREATE TABLE products (
276276 product_no integer,
277277 name text,
278- price numeric <emphasis>CHECK (price> 0)</emphasis>
278+ price numeric <emphasis>CHECK (price> 0)</emphasis>
279279);
280280</programlisting>
281281 </para>
@@ -303,7 +303,7 @@ CREATE TABLE products (
303303CREATE TABLE products (
304304 product_no integer,
305305 name text,
306- price numeric <emphasis>CONSTRAINT positive_price</emphasis> CHECK (price> 0)
306+ price numeric <emphasis>CONSTRAINT positive_price</emphasis> CHECK (price> 0)
307307);
308308</programlisting>
309309 So, to specify a named constraint, use the key word
@@ -320,9 +320,9 @@ CREATE TABLE products (
320320CREATE TABLE products (
321321 product_no integer,
322322 name text,
323- price numeric CHECK (price> 0),
324- discounted_price numeric CHECK (discounted_price> 0),
325- <emphasis>CHECK (price> discounted_price)</emphasis>
323+ price numeric CHECK (price> 0),
324+ discounted_price numeric CHECK (discounted_price> 0),
325+ <emphasis>CHECK (price> discounted_price)</emphasis>
326326);
327327</programlisting>
328328 </para>
@@ -350,20 +350,20 @@ CREATE TABLE products (
350350 product_no integer,
351351 name text,
352352 price numeric,
353- CHECK (price> 0),
353+ CHECK (price> 0),
354354 discounted_price numeric,
355- CHECK (discounted_price> 0),
356- CHECK (price> discounted_price)
355+ CHECK (discounted_price> 0),
356+ CHECK (price> discounted_price)
357357);
358358</programlisting>
359359 or even
360360<programlisting>
361361CREATE TABLE products (
362362 product_no integer,
363363 name text,
364- price numeric CHECK (price> 0),
364+ price numeric CHECK (price> 0),
365365 discounted_price numeric,
366- CHECK (discounted_price> 0 AND price> discounted_price)
366+ CHECK (discounted_price> 0 AND price> discounted_price)
367367);
368368</programlisting>
369369 It's a matter of taste.
@@ -377,10 +377,10 @@ CREATE TABLE products (
377377 product_no integer,
378378 name text,
379379 price numeric,
380- CHECK (price> 0),
380+ CHECK (price> 0),
381381 discounted_price numeric,
382- CHECK (discounted_price> 0),
383- <emphasis>CONSTRAINT valid_discount</> CHECK (price> discounted_price)
382+ CHECK (discounted_price> 0),
383+ <emphasis>CONSTRAINT valid_discount</> CHECK (price> discounted_price)
384384);
385385</programlisting>
386386 </para>
@@ -442,7 +442,7 @@ CREATE TABLE products (
442442CREATE TABLE products (
443443 product_no integer NOT NULL,
444444 name text NOT NULL,
445- price numeric NOT NULL CHECK (price> 0)
445+ price numeric NOT NULL CHECK (price> 0)
446446);
447447</programlisting>
448448 The order doesn't matter. It does not necessarily determine in which