From: | GB Clark <postgres(at)vsservices(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Constraint problems |
Date: | 2002-09-27 19:56:52 |
Message-ID: | 20020927145652.4c82624e.postgres@vsservices.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Fri, 27 Sep 2002 11:29:34 -0700 (PDT)
Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> wrote:
> 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?
>
Thanks! The FK was just what I was looking for. I had not relized that I could
do a current table reference in a FK declaration.
Thanks,
GB
--
GB Clark II | Roaming FreeBSD Admin
gclarkii(at)VSServices(dot)COM | General Geek
CTHULU for President - Why choose the lesser of two evils?
From | Date | Subject | |
---|---|---|---|
Next Message | Ian Barwick | 2002-09-27 20:16:28 | Re: PL/pgsql |
Previous Message | Josh Berkus | 2002-09-27 19:05:49 | PGSQL-Performance mailing list. |