postgresql语句

查询oracle数据库所有表数据量

select t.table_name,t.num_rows from user_tables t ORDER BY t.num_rows desc

查询postgresql数据库所有表数据量

select table_schema || '.' || table_name as table_full_name,
pg_size_pretty(pg_total_relation_size('"' || table_schema || '"."' || table_name || '"')) as size
from information_schema.tables
order by
pg_total_relation_size('"' || table_schema || '"."' || table_name || '"') desc

改变配置

pg_ctl reload

分组取前几条:

https://blog.csdn.net/a258831020/article/details/48497929

select t.* from (select serial_group_id, total,year, month, row_number() over(partition by serial_group_id ORDER BY year desc,month desc) as row from ap_serial_group_sales ORDER BY year desc) t where  row<=1

相加:

(coalesce(t.local_price,0)+coalesce(t.manu_price,0)+coalesce(t.country_price,0)) btotal

逗号合并:

select  array_to_string(ARRAY(SELECT unnest(array_agg(t.id)) ),',')
from (
select n.id
from ap_group_photo_node n
left join ap_group_photo_node_ex ex on ex.group_photo_node_id = n.id
left join ap_photo p on n.id = p.group_photo_node_id
where n.enabled = 1 and n.deleted = 0 and n.photo_amount > 0 and p.enabled=1
group by n.id
order by n.id
limit 100
) t

相同id的合并值:

https://my.oschina.net/Kenyon/blog/86609

上一篇:2、Lucene 最简单的使用(小例子)


下一篇:ArcGIS Runtime SDKs v10.2.4最新(Android、iOS、OSX和.NET)