我想显示任何表达式类型名称。类似于python中的"type"函数。
要像这样工作:
select type(1);
'int'
select type(ROW(1, 'abc'));
'row(int, text)'
select type(select * from t1);
'setof t1'
postgresql 中有这样的东西吗?
它
被称为pg_typeof()
,尽管它不完全是你想要的
select pg_typeof(1), ROW(1, 'abc');
返回
pg_typeof | row
----------+--------
integer | (1,abc)
但是你不能使用 pg_typeof(select * from t1)
,即使有limit 1
也不能,因为该函数需要单个表达式作为其输入,而不是多列。但是,您可以执行以下操作:pg_typeof((select some_column from t1))