to_regtype()

A function translating a type name to an OID

to_regtype() is a system function for translating a data type name to its OID

to_regtype() was added in PostgreSQL 9.4.

Usage

to_regtype ( text ) → regtype

to_regtype()is equivalent to using the regtype cast, but returns NULL rather than raising an ERROR if no matching data type is found.

The current search path is considered when evaluating the provided data type name.

Change history

Examples

Basic usage example for to_regtype():

postgres=# SELECT to_regtype('int')::oid;
 to_regtype 
------------
         23
(1 row)

Categories

Data type, System function

See also

regtype