Skip to main content

Overview

The pg_typeof() is a system catalog information function that retrieves the data type of any given value. It returns a string literal corresponding to the expression type.

Syntax

The syntax of the pg_typeof() function is as follows:

Parameters

The following parameters are required to execute this function:
  • any: represents any value you want to determine the data type of

Examples

Numeric

This example shows the function usage with a numeric value:

String

In this example, we will use a string value as an input:

Interval

Here we will focus on using an interval input:

Table

For the needs of this section we will create a sample table and then use pg_typeof() to retrieve the data types of information stored in the table
Now that we created the table, let’s use pg_typeof() function to determine the data types of the event_time and description columns for each row
By executing the query above we will get the following output