| From: | Alexander Dobikov <alex(dot)dobikov(at)gmail(dot)com> |
|---|---|
| To: | pgsql-general-owner(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org |
| Subject: | Sequence |
| Date: | 2008-07-25 04:47:56 |
| Message-ID: | 48895AFC.8060907@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Hello.
A table has two primary keys: CREATE TABLE example ( pk1 integer, pk2
integer, PRIMARY KEY (pk1, pk2) ). To add a new record I use command:
INSERT INTO example (pk1, pk2) VALUES (0, 0). Before adding the new
record I have to find out the last value of pk2. How can I use something
like this: INSERT INTO example (pk1, pk2) VALUES (0, nextval('pk2'))?
If a table just has one primary key I can use sequence (CREATE
SEQUENCE). What about two primary keys?
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alexander Dobikov | 2008-07-25 04:53:34 | Sequence |
| Previous Message | Chris | 2008-07-25 04:18:06 | Re: php + postgresql |