From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | Tom Janssens <tom-janssens(at)freegates(dot)be> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: QUESTION: Automatically generating Primary keys !!! |
Date: | 2001-06-07 06:27:29 |
Message-ID: | 3B1F1ED1.BD209EB@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Tom Janssens wrote:
> My problem is that I should be able to let the Database System (Postgresql)
> generate its own primairy keys (from the rest of the data).
> workplace_ID, name, street, nr, zipcode, city, country
>
> workplace_ID is the primairy key of that table. Some other tables have a
> foreign key refering to it. As a primairy key this ID is of course unique.
> My Question is: How can I see which values (of the primairy key) are already
> taken, and which is available for new data.
Other than with SELECT?
If it's not too late, I'd make workplace_ID into a serial and let
PostgreSQL generate the values for you.
If it is too late, and workplace_id is text you could try appending
nextval(some_seq) to the end of it - that would guarantee uniqueness.
- Richardh
From | Date | Subject | |
---|---|---|---|
Next Message | Pätzke Axel (external) | 2001-06-07 07:11:28 | PostgreSQL 7.1 and ORACLE 8.x |
Previous Message | Martín Marqués | 2001-06-07 06:26:52 | Re: [HACKERS] something smells bad |