Re: identity columns ?
От | Joshua b. Jore |
---|---|
Тема | Re: identity columns ? |
Дата | |
Msg-id | Pine.BSO.4.40.0204051100460.2976-100000@kitten.greentechnologist.org обсуждение исходный текст |
Ответ на | Re: identity columns ? ("Josh Berkus" <josh@agliodbs.com>) |
Ответы |
Re: identity columns ?
|
Список | pgsql-novice |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 So this raises a question I was wondering, what use *is* the oid column in non-system tables? The only thing I could think of is for last-resort row uniqueness if the application somehow borked up. Are there any other reasons to even have this column in a user table? Joshua b. Jore http://www.greentechnologist.org On Fri, 5 Apr 2002, Josh Berkus wrote: > 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 > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org > -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (OpenBSD) Comment: For info see http://www.gnupg.org iD8DBQE8rdkofexLsowstzcRAsDcAKDfShTlMHsD/atFKi0XcgQOODk+TQCg7Ka0 TO9O4+J007jd8v9W0oOlhYs= =8hjf -----END PGP SIGNATURE-----
В списке pgsql-novice по дате отправления: