Types and type casting in #PostgreSQL
To see the type of column or any entity in PostgreSQL use pg_typeof
. Here's an example:
select pg_typeof(array['thing']);
-- OUTPUT:
-- pg_typeof
-- ---------
-- text[]
To cast to another type use the ::
operator:
select pg_typeof(array['thing']::varchar[]);
-- OUTPUT:
-- pg_typeof
-- -------------------
-- character varying[]
h/t Josh Branchaud
Tweet