postgres常用查询集锦

查询pg中每个表的统计量信息(在非精确的数据条数统计下适用):

-- 查询public的schema下所有表的统计条数(预估值)
SELECT relname, reltuples 
FROM pg_class r JOIN pg_namespace n 
ON (relnamespace = n.oid) 
WHERE relkind = 'r' AND n.nspname = 'public';
postgis geometry转text,配套后面js使用

create or replace function geom_to_text(geometry) returns text as
$$

	select replace( replace(replace(st_astext(st_multi($1)) , 'MULTIPOLYGON(((' ,'' ) , ')))' , '' ) , ')),((' , ';')  

$$
language sql immutable ; 

  

后面不定期更新

猜你喜欢

转载自jjxliu306.iteye.com/blog/2384018