From: | "Josh Berkus" <josh(at)agliodbs(dot)com> |
---|---|
To: | Harald Lux <info(at)lux(dot)de>, "Chris" <chris(at)netlabz(dot)com> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: identity columns ? |
Date: | 2002-04-05 16:21:53 |
Message-ID: | web-1050282@davinci.ethosmedia.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Harald, Chris,
> > 1. M$ SQL Server has an identity column which generates a
> sequential number
> > for you, we use this often for unique primary keys. Does postgres
> support
> > anything like this ?
>
> select *,oid from your_table
NO!!!! This is wrong. DO NOT USE the oid for anything other than
system purposes. It is NOT a user-friendly value for several reasons.
Chris, the data type you want is SERIAL. Please read the section of
the docs on sequences:
http://www.postgresql.org/idocs/index.php?sql-createsequence.html
... as the SERIAL datatype simply automates the creation of a sequence.
BTW, postgres sequences are both more powerful and more user-friendly
than MS SQL Identity columns.
I would also strongly suggest buying a beginner's postgresql book, such
as "PostgreSQL: Introduction and Concepts" or Wrox Press' PostgreSQL
book.
-Josh Berkus
From | Date | Subject | |
---|---|---|---|
Next Message | Joshua b. Jore | 2002-04-05 17:04:38 | Re: identity columns ? |
Previous Message | PGMailList | 2002-04-05 10:03:39 | Re: identity columns ? |