Thread: automatic creation of oid

automatic creation of oid

From
Detlef Jockheck
Date:
Hi,

I'm new to postgresql. How can automatically create unique object identifyer
during insertion of new data. I 've seen that a can use a sequence, but I
think there must be another way?

ciao
Detlef

--
# Dipl. Ing. (FH) Detlef Jockheck
# E-mail: detlef@jockheck.de
# -------------------------------

Re: automatic creation of oid

From
Oliver Elphick
Date:
On Fri, 2003-02-28 at 20:10, Detlef Jockheck wrote:
> Hi,
>
> I'm new to postgresql. How can automatically create unique object identifyer
> during insertion of new data. I 've seen that a can use a sequence, but I
> think there must be another way?

Why must there?  Using a sequence is the correct way to do it.  To
automate the process, declare a column of SERIAL type.  (SERIAL is
shorthand for creating a sequence and attaching it to the column's
default.)

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight, UK                             http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "These things have I written unto you that believe on
      the name of the Son of God; that ye may know that ye
      have eternal life, and that ye may believe on the name
      of the Son of God."        I John 5:13


Re: automatic creation of oid

From
Detlef Jockheck
Date:
Am Samstag, 1. März 2003 00:45 schrieben Sie:
> On Fri, 2003-02-28 at 20:10, Detlef Jockheck wrote:
> > Hi,
> >
> > I'm new to postgresql. How can automatically create unique object
> > identifyer during insertion of new data. I 've seen that a can use a
> > sequence, but I think there must be another way?
>
> Why must there?  Using a sequence is the correct way to do it.  To
> automate the process, declare a column of SERIAL type.  (SERIAL is
> shorthand for creating a sequence and attaching it to the column's
> default.)
Hi Oliver,

Yes! Thats what I was looking for. I've seen it in the documentation but
could'nt remember how it works. Thanks for the tip :-)

ciao
Detlef


--
# Dipl. Ing. (FH) Detlef Jockheck
# E-mail: detlef@jockheck.de
# -------------------------------

Re: automatic creation of oid

From
Lincoln Yeoh
Date:
At 09:10 PM 2/28/03 +0100, Detlef Jockheck wrote:
>I'm new to postgresql. How can automatically create unique object identifyer
>during insertion of new data. I 've seen that a can use a sequence, but I
>think there must be another way?

There are other options. But if you don't have any other requirements than
what you mentioned, you should use sequence/serial.

Regards,
Link.