Re: about data type id

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>
Cc: "Jinqiang Han" <postgresql(at)db(dot)pku(dot)edu(dot)cn>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: about data type id
Date: 2002-12-24 05:53:43
Message-ID: 17489.1040709223@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au> writes:
> Try: SELECT oid FROM pg_type WHERE typname='text';

Another possibility (as of 7.3) is

regression=# select 'int4'::regtype::oid;
oid
-----
23
(1 row)

The regtype converter has the advantage that it will recognize any
typename construct understood by the parser, for example

regression=# select 'character varying'::regtype::oid;
oid
------
1043
(1 row)

Also, regtype will do the right thing in the presence of schema-related
ambiguities (eg, 'a.foo' and 'b.foo' may both exist in the catalog,
but if only b is in your search path, 'foo' should mean 'b.foo').

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Vadim Mikheev 2002-12-24 06:33:01 Re: PostgreSQL-R
Previous Message Christopher Kings-Lynne 2002-12-24 03:07:44 Re: about data type id