一个比较好的学习postgres的站点
http://www.postgresqltutorial.com
显示当前连接数
1 | select sum(numbackends) FROM pg_stat_database; |
1 | --切换数据库 |
重建主键
1 | -- Firstly, remove PRIMARY KEY attribute of former PRIMARY KEY |
让主键自增
1 | create sequence <table_name_primary_id_seq>; |
导出insert语句
1 | pg_dump --column-inserts --data-only -d <database> -t <table> > ./export.sql |
计算百分比
1 | select count(*) as item,(count(*)::decimal / (select count(*) from <table>)::decimal) * 100 as percent |
postgis应用
http://www.gonjay.com/blog/2015/05/15/postgis-cha-xun-fu-jin-de-ren/