From: | Stephen van Egmond <svanegmond(at)bang(dot)dhs(dot)org> |
---|---|
To: | "Julio Cuz, Jr(dot)" <jcuz(at)rccd(dot)cc(dot)ca(dot)us> |
Cc: | pgsql-php(at)postgresql(dot)org |
Subject: | Re: Automatic increment |
Date: | 2001-01-12 03:22:05 |
Message-ID: | 20010111222205.A31717@bang.dhs.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-php pgsql-sql |
Julio Cuz, Jr. (jcuz(at)rccd(dot)cc(dot)ca(dot)us) wrote:
> Some of you guys suggested to use the 'SERIAL' type for a field that needs
> to be AUTOMATICALLY INCREASED BY 1 by PGSQL without user intervention, but
> it doesn't seem to work. What am I doing wrong?
Though I wasn't here for that, here's how I normally declare
automatically-incrementing values:
CREATE SEQUENCE foo_id;
CREATE TABLE foo (
foo_id integer not null primary key default nextval(foo_id);
...
);
insertions to foo get their own unique ID. With the php extension, you
can get the oid of the row that was inserted and go get the ID if you
happen to need it.
From | Date | Subject | |
---|---|---|---|
Next Message | GH | 2001-01-12 03:25:23 | Re: Automatic increment |
Previous Message | GH | 2001-01-12 03:20:08 | Re: Automatic increment |
From | Date | Subject | |
---|---|---|---|
Next Message | GH | 2001-01-12 03:25:23 | Re: Automatic increment |
Previous Message | GH | 2001-01-12 03:20:08 | Re: Automatic increment |