2016-05-12 99 views
1

我从PostgreSQL数据库中提取数据。所有工作正常,但是我想选择data_type的大小,但是我不能让它工作。请帮助这里是我的查询:提取数据类型大小PostgreSQL

$result2 = pg_query($dbconn, "SELECT table_name as tabela, column_name as campo, data_type as tipo from information_schema.columns where table_schema = 'public'"); 

回答

1

你的sql工作正常。

我想说你的用户没有权限(读)到表(S)其要求查看?

你可以试试这个

GRANT SELECT ON ALL TABLES IN SCHEMA PUBLIC TO youruser; 

对于列的大小你可能在你的系统管理功能

pg_column_size(data_type) 

“pg_column_size(任何)返回INT是哪个用于存储特定值(可能被压缩)的字节数“

SELECT table_name as tabela, column_name as campo, 
data_type as tipo,pg_column_size(data_type) as tipo1 from 
information_schema.columns where table_schema = 'public' 

结果

Postgresql Results set using pg_column_size

参考Postgresql 9.5 section 9.26. System Administration Functions

所有最优秀的

+0

我知道我的SQL工作正常,但我想是这样 column_length的长度得到的大小该领域...如果可能的话:( – Boltz0r

+0

您好@ Boltz0r我希望这是你在找什么?所有最好的 – pnorton

+0

我不确定他是否给我的类型本身的大小或“整数”f ex的大小......但这是一些东西;)我会把它算作解决:D谢谢! – Boltz0r