Re: OID of type by name.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dmitriy Igrishin <dmitigr(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: OID of type by name.
Date: 2010-12-08 14:57:53
Message-ID: 14659.1291820273@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dmitriy Igrishin <dmitigr(at)gmail(dot)com> writes:
>> How can I get OID by name rather than alias ?

> SELECT oid FROM pg_type WHERE typtype = 'b' AND typarray <> 0 AND
> typname::regtype = 'integer';

Seems like the hard way --- if you think carefully about what regtype
is doing, you'll realize that this is incredibly inefficient, as well
as a lot of typing. I usually do SELECT 'integer'::regtype::oid
when I need a quick numeric lookup.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dmitriy Igrishin 2010-12-08 15:01:54 Re: OID of type by name.
Previous Message Adrian Klaver 2010-12-08 14:34:26 Re: Maximum size for char or varchar with limit