Обсуждение: Schema and Namespace Oid confusion

Поиск
Список
Период
Сортировка

Schema and Namespace Oid confusion

От
ZongtianHou
Дата:
Hi, everyone

I get somehow confused when I learn about namespace here, there are two questions,
First, what is the difference between namespace and schema?
Second, why the Oid of public namespace is 2200, the same between databases? Does oid is unique for every object across
cluster? 

Does someone know about these clearly?

Re: Schema and Namespace Oid confusion

От
Alvaro Herrera
Дата:
Hello

On 2018-Dec-28, ZongtianHou wrote:

> I get somehow confused when I learn about namespace here, there are two questions,
> First, what is the difference between namespace and schema?

None.  Schema is the user-visible name for the feature; namespace is the
source code and system catalog level.

> Second, why the Oid of public namespace is 2200, the same between
> databases?

Not necessarily.  That's the initial value, but it's possible to drop
the public schema and create it afresh.

> Does oid is unique for every object across cluster? 

No, only inside each individual catalog are OIDs guaranteed unique.

> Does someone know about these clearly?

Yes.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


Re: Schema and Namespace Oid confusion

От
Tom Lane
Дата:
ZongtianHou <zongtianhou@icloud.com> writes:
> First, what is the difference between namespace and schema?

None.

> Second, why the Oid of public namespace is 2200, the same between databases? Does oid is unique for every object
acrosscluster?  

CREATE DATABASE physically clones the template database, so all objects
have the same OIDs they had in the template.  OID uniqueness is only
expected for objects within one database (and even then, only across
objects in the same system catalog), not across the whole cluster.

            regards, tom lane


Re: Schema and Namespace Oid confusion

От
ZongtianHou
Дата:
Thank you very much, got it.
> On 28 Dec 2018, at 11:36 PM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
>
> Hello
>
> On 2018-Dec-28, ZongtianHou wrote:
>
>> I get somehow confused when I learn about namespace here, there are two questions,
>> First, what is the difference between namespace and schema?
>
> None.  Schema is the user-visible name for the feature; namespace is the
> source code and system catalog level.
>
>> Second, why the Oid of public namespace is 2200, the same between
>> databases?
>
> Not necessarily.  That's the initial value, but it's possible to drop
> the public schema and create it afresh.
>
>> Does oid is unique for every object across cluster?
>
> No, only inside each individual catalog are OIDs guaranteed unique.
>
>> Does someone know about these clearly?
>
> Yes.
>
> --
> Álvaro Herrera                https://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>