pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
To: GB Clark <postgres@vsservices.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Constraint problems
Date: Fri, 27 Sep 2002 11:29:34 -0700 (PDT)
Message-ID: <20020927112807.D42421-100000@megazone23.bigpanda.com> (raw)
In-Reply-To: <20020927131547.09ed1af2.postgres@vsservices.com>

On Fri, 27 Sep 2002, GB Clark wrote:

> CREATE TABLE sysusers (
> user_id			INTEGER DEFAULT nextval('sysusers_user_id_seq')
> 					UNIQUE NOT NULL PRIMARY KEY,
> username			text NOT NULL UNIQUE,
> password			text NOT NULL,
>
> createby			text NOT NULL DEFAULT 'syscreate',
>
> status			char(1) DEFAULT 'A' CHECK (status in ('A', 'I')),
> comment1			text,
> comment2			text,
> tstamp			timestamp DEFAULT CURRENT_TIMESTAMP
> );
>
> CREATE UNIQUE INDEX username_unique_idx ON sysusers (username);
>
> INSERT INTO sysusers (username, password, createby) VALUES ('syscreate', 'testing', 'syscreate');
>
> ALTER TABLE sysusers ADD CONSTRAINT createby_test CHECK (createby in (username));

This is only going to check the value of username in the current row.

Why not use a foreign key from createby to username?





view thread (3+ messages)  latest in thread

Message-ID: <20020927112807.D42421-100000@megazone23.bigpanda.com>
Permalink:  ../20020927112807.D42421-100000@megazone23.bigpanda.com/
Also on:    postgresql.org/message-id/20020927112807.D42421-100000@megazone23.bigpanda.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: sszabo@megazone23.bigpanda.com, postgres@vsservices.com
  Subject: Re: Constraint problems
  In-Reply-To: <20020927112807.D42421-100000@megazone23.bigpanda.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox