how to check type of value in postgres

If anyone else wonders How to just get data type of a varible (not column) you can use the pg_typeof(any) function.

Simply

SELECT pg_typeof(your_variable);

OR

SELECT pg_typeof('{}'::text[]); //returns text[];

Note

pg_typeof(varchar_column) will return character varying regardless of
the content of the column. Any column or variable is already typed and
pg_typeof will return that declared type. It will not find the “best
fitting” type depending on the value of that column (or variable). — quote from a_horse_with_no_name’s comment.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)