I would like to show any expression type name. Something like 'type' function in python.
To work somewhat like these:
select type(1);
'int'
select type(ROW(1, 'abc'));
'row(int, text)'
select type(select * from t1);
'setof t1'
Is there anything like this in postgresql?
It's called pg_typeof()
although it's not exactly what you want
select pg_typeof(1), ROW(1, 'abc');
Returns
pg_typeof | row
----------+--------
integer | (1,abc)
You can't however use pg_typeof(select * from t1)
, not even with a limit 1
because the function requires a single expression as its input, not multiple columns. You could however do something like: pg_typeof((select some_column from t1))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With