Thread: Problems with OIDs

Problems with OIDs

From
Carlos García Gómez
Date:
Hi all!

I've got the following problem: I had a view with OID 5330 that had to be
removed from the database, afterwards I created again a view (with the same
name, because I need it to be this way) and get the an error telling me that
the view with OID 5330 cannot be found, How can I solve it??

Thank u all!!


Re: Problems with OIDs

From
"Adrian Tineo"
Date:
From excellent Momjian's online book (URL for the extract is
http://www.ca.postgresql.org/docs/aw_pgsql_book/node71.html):

"Every row in POSTGRESQL is assigned a unique, normally invisible number
called an object identification number (OID). When the software is
initialized with initdb, a counter is created and set to approximately
seventeen-thousand. The counter is used to uniquely number every row.
Although databases may be created and destroyed, the counter continues to
increase. It is used by all databases, so identification numbers are always
unique. No two rows in any table or in any database will ever have the same
object ID."

So you can't have a view with the same OID, use another primary key instead.

The index for the book is
http://www.postgresql.org/docs/aw_pgsql_book/index.html. I learned a lot
from there!! Check it.

Adrian Tineo

> I've got the following problem: I had a view with OID 5330 that had to be
> removed from the database, afterwards I created again a view (with the
same
> name, because I need it to be this way) and get the an error telling me
that
> the view with OID 5330 cannot be found, How can I solve it??


Re: Problems with OIDs

From
Andrew McMillan
Date:
On Thu, 2002-10-24 at 19:39, Carlos García Gómez wrote:
> Hi all!
>
> I've got the following problem: I had a view with OID 5330 that had to be
> removed from the database, afterwards I created again a view (with the same
> name, because I need it to be this way) and get the an error telling me that
> the view with OID 5330 cannot be found, How can I solve it??

You need to redefine the thing that you do not mention which refers to
the view - possibly this may be another view.

When you recreate that, it will be created referencing the correct OID.

Regards,
                    Andrew.
--
---------------------------------------------------------------------
Andrew @ Catalyst .Net.NZ Ltd, PO Box 11-053, Manners St,  Wellington
WEB: http://catalyst.net.nz/         PHYS: Level 2, 150-154 Willis St
DDI: +64(4)916-7201     MOB: +64(21)635-694    OFFICE: +64(4)499-2267
           Survey for free with http://survey.net.nz/
---------------------------------------------------------------------


Re: Problems with OIDs

From
"Jules Alberts"
Date:
On 24 Oct 2002 at 8:39, Carlos García Gómez wrote:
> Hi all!
>
> I've got the following problem: I had a view with OID 5330 that had to be
> removed from the database, afterwards I created again a view (with the same
> name, because I need it to be this way) and get the an error telling me that
> the view with OID 5330 cannot be found, How can I solve it??

OID's change when you do a dump / restore. Never use hardcoded OIDs in
your app!