| | |
| | | ----------------------------------------------------------------------------------------------------- 1.查询连接数 |
| | | ----------------------------------------------------------------------------------------------------- 0.查询连接数 |
| | | show max_connections; |
| | | select count(1) from pg_stat_activity; |
| | | |
| | |
| | | select fn_rec_array(1, 'dep'); |
| | | select fn_rec_array(10, 'dir'); |
| | | select * from lf.sys_user a where a.depid=ANY(fn_rec_array(15,'dep')); |
| | | ----------------------------------------------------------------------------------------------------- g.索引 |
| | | ----------------------------------------------------------------------------------------------------- g.获取实体名 |
| | | create or replace function fn_get_entity(tab varchar) |
| | | returns varchar as $$ |
| | | declare |
| | | str varchar; |
| | | rs varchar = ''; |
| | | begin |
| | | foreach str in array (select string_to_array(tab, '_')) loop |
| | | if (length(rs) = 0 or length(str) = 1) then |
| | | rs = rs || str; |
| | | else |
| | | rs = rs || initcap(str); |
| | | end if; |
| | | end loop; |
| | | |
| | | return rs; |
| | | end; |
| | | $$ language plpgsql; |
| | | |
| | | select fn_get_entity('dlg_25w_boua_s'); select fn_get_entity('dlg_25w_vega'); |
| | | ----------------------------------------------------------------------------------------------------- h.索引 |
| | | alter table lf.sys_role_user add constraint idx_unique_role_user unique (roleid, userid); -- 联合唯一索引 |
| | | insert into lf.sys_role_user (roleid,userid) values (1,1); -- 测试 |
| | | select * from lf.sys_role_user; |
| | |
| | | alter table lf.sys_role_menu_auth add constraint idx_unique_role_menu_auth unique (roleid,menu_auth_id); -- 联合唯一索引 |
| | | insert into lf.sys_role_menu_auth (roleid,menu_auth_id) values (1,1); |
| | | select * from lf.sys_role_menu_auth; |
| | | ----------------------------------------------------------------------------------------------------- |
| | | ----------------------------------------------------------------------------------------------------- i.联合查询 |
| | | select a.*,fn_uname(a.create_user) createUserName,fn_uname(a.update_user) updateUserName from lf.sys_blacklist a order by a.id; |
| | | select * from lf.sys_user a where uname like '%' and a.depid=ANY(fn_rec_array(1,'dep')); |
| | | select * from lf.sys_user a left join lf.sys_role_user b on a.id=b.userid |
| | |
| | | update lf.sys_operate set modular1='运维管理',modular2='资源管理' where position('/res/select' in url)>0 and (modular1 is null or modular2 is null); |
| | | |
| | | delete from lf.sys_operate where modular1 is null or modular2 is null; |
| | | ----------------------------------------------------------------------------------------------------- |
| | | ----------------------------------------------------------------------------------------------------- j.查询授权 |
| | | select gid,gb,name,st_astext(a.geom) from bd.dlg_agnp a; |
| | | |
| | | -- 根据用户Uid查询资源 |
| | |
| | | inner join lf.sys_menu e on d.menuid = e.id |
| | | inner join lf.sys_auth f on d.authid = f.id |
| | | where a.uid = 'admin'; |
| | | ---------------------------------------------------------------------------------------------- 数据统计 |
| | | ---------------------------------------------------------------------------------------------- k.数据统计 |
| | | select modular2,count(*) from lf.sys_operate group by modular2; |
| | | |
| | | select to_char(optime,'yyyy-mm-dd') as optime,count(*) from lf.sys_login where optime between (select optime - interval '30 day') |
| | | and optime group by to_char(optime, 'yyyy-mm-dd') order by to_char(optime, 'yyyy-mm-dd') asc; |
| | | ----------------------------------------------------------------------------------------------------- |
| | | select a.*,coalesce(a.native,'') from lf.sys_user a; |
| | | select * from lf.sys_menu order by id; |
| | | |
| | | select * from lf.sys_blacklist where type = 1; |
| | | select * from lf.sys_operate where modular1 is null or modular2 is null; |
| | | select count(*) from bd.dlg_agnp; |
| | | select count(*) from bd.dlg_25w_aanp; |
| | | select ST_PointFromText('POINT(95.80461853400004 34.13862467200005)'); |
| | | select ST_LineFromText('LINESTRING(04.98985101830993 37.43840773692756,104.99318913447104 37.43883729720358)', 4326); |
| | | select ST_PolygonFromText('POLYGON((104.9907822932683 37.43532941961706,104.99088987736599 37.43532941961706,104.9908670336867 37.4349030213574,104.99078327712658 37.4349030213574,104.9907822932683 37.43532941961706))',4326); |
| | | |
| | | -- 114ms,180/3248 |
| | | select count(1) from bd.dlg_agnp a where ST_Intersects(a.geom, |
| | | select count(1) from bd.dlg_agnp a where ST_Intersects(geom, |
| | | ST_PolygonFromText('POLYGON ((115.94927385452 32.3754479115071 0,121.989371092554 32.2766788010181 0,121.850621222894 29.6874200067864 0,115.9727267226 29.7835368627922 0,115.94927385452 32.3754479115071 0))', 4326)) |
| | | |
| | | -- |
| | | with geo as (select ST_PolygonFromText('POLYGON ((115.94927385452 32.3754479115071 0,121.989371092554 32.2766788010181 0,121.850621222894 29.6874200067864 0,115.9727267226 29.7835368627922 0,115.94927385452 32.3754479115071 0))', 4326)) |
| | | select count(1) from bd.dlg_25w_aanp a where ST_Intersects(geo, geom); |
| | | -- 1101:gid >= 50 and name like '县' and objectid < 5000.0 and pac = '360430' |
| | | select count(*) from bd.dlg_agnp where gid >= 50 and name like '%县%' and objectid < 5000 --and pac = '360430' |
| | | and ST_Intersects(geom, |
| | | ST_PolygonFromText('POLYGON ((115.94927385452 32.3754479115071 0,121.989371092554 32.2766788010181 0,121.850621222894 29.6874200067864 0,115.9727267226 29.7835368627922 0,115.94927385452 32.3754479115071 0))', 4326)) |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |