2017-01-30 108 views
1

我想显示任何表达式类型的名称。 python中的'type'函数。如何显示postgresql表达式类型?

要有点像工作这些:

select type(1); 
'int' 

select type(ROW(1, 'abc')); 
'row(int, text)' 

select type(select * from t1); 
'setof t1' 

有没有这样的PostgreSQL中什么?

回答

5

这就是所谓的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))

相关问题