Get data type aliases

Started by Rebecca Clarkealmost 13 years ago3 messagesgeneral
Jump to latest
#1Rebecca Clarke
r.clarke83@gmail.com

Hi all.

I have a function that has an attribute with datatype of character varying.
In the pg_type table the oid of the data type points to type varchar

Is there somewhere that identifies the alias for each type?

E.g.
int4 = integer
varchar = character varying.
and so on.

I can do an if statement in my code but I'd prefer not to.

Thanks in advance.

Rebecca

#2Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Rebecca Clarke (#1)
Re: Get data type aliases

Rebecca Clarke escribi�:

Hi all.

I have a function that has an attribute with datatype of character varying.
In the pg_type table the oid of the data type points to type varchar

Is there somewhere that identifies the alias for each type?

Cast the type name to regtype. That outputs the "official" name.

alvherre=# select 'int'::regtype;
regtype
---------
integer
(1 fila)

--
�lvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3Rebecca Clarke
r.clarke83@gmail.com
In reply to: Alvaro Herrera (#2)
Re: Get data type aliases

That's great, thank you! worked like a charm.

On Wed, Jun 12, 2013 at 8:31 PM, Alvaro Herrera <alvherre@2ndquadrant.com>wrote:

Show quoted text

Rebecca Clarke escribió:

Hi all.

I have a function that has an attribute with datatype of character

varying.

In the pg_type table the oid of the data type points to type varchar

Is there somewhere that identifies the alias for each type?

Cast the type name to regtype. That outputs the "official" name.

alvherre=# select 'int'::regtype;
regtype
---------
integer
(1 fila)

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