Skip to content

Instantly share code, notes, and snippets.

@taross-f
Created February 5, 2019 03:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taross-f/59f034a30fe80937471d5cdfca35eaf3 to your computer and use it in GitHub Desktop.
Save taross-f/59f034a30fe80937471d5cdfca35eaf3 to your computer and use it in GitHub Desktop.
useful sql
select name, MB from
(
select tbl, count(*) as MB
from stv_blocklist
where tbl in (
select id
from stv_tbl_perm)
group by tbl
) block_list
inner join stv_tbl_perm
on block_list.tbl=stv_tbl_perm.id
group by tbl, stv_tbl_perm.name, block_list.MB
order by MB desc;
SELECT
use.usename as subject,
nsp.nspname as namespace,
c.relname as item,
c.relkind as type,
use2.usename as owner,
c.relacl
FROM
pg_user use
cross join pg_class c
left join pg_namespace nsp on (c.relnamespace = nsp.oid)
left join pg_user use2 on (c.relowner = use2.usesysid)
WHERE
c.relowner = use.usesysid
and nsp.nspname NOT IN ('pg_catalog', 'pg_toast', 'information_schema')
and nsp.nspname in('public','master') /** 任意のスキーマを指定 */
and type in('r','v')
ORDER BY
subject,namespace,item;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment