pg_typeof()

A function returning the data type of the provided value

pg_typeof() is a system function returning the data type of the provided value.

pg_typeof() was added in PostgreSQL 8.4.

Usage

pg_typeof ( "any" ) → regtype

pg_typeof() returns the type as regtype, which can be used as an OID for comparision purposes, but otherwise will return the human-readable type name.

Change history

Examples

Basic usage example for pg_typeof():

postgres=# SELECT pg_typeof(123), pg_typeof(1.23);
 pg_typeof | pg_typeof
-----------+-----------
 integer   | numeric
(1 row)

Categories

Data type, System catalogue, System function

See also

pg_type_is_visible(), json_typeof()