# HG changeset patch # User Oleksandr Gavenko # Date 1546501196 -7200 # Node ID 738316fb865f5089c986c52bdfa4bda8d2beefd7 # Parent 71c08bde5a3c6e12fe4ab2af441abed7bf44a1c0 Grant role options. diff -r 71c08bde5a3c -r 738316fb865f postgres.rst --- a/postgres.rst Thu Jan 03 00:32:48 2019 +0200 +++ b/postgres.rst Thu Jan 03 09:39:56 2019 +0200 @@ -67,6 +67,22 @@ SELECT * FROM pg_available_extensions; +Grant role options +================== +:: + + ALTER USER me WITH SUPERUSER; + ALTER USER me WITH CREATEDB CREATEROLE LOGIN; + +https://www.postgresql.org/docs/current/sql-createrole.html + ``CREATE ROLE``. + +Change password +=============== +:: + + ALTER USER me WITH PASSWORD 'PassWord'; + List databases, schemas and tables ================================== @@ -121,6 +137,49 @@ select * from pg_indexes where schemaname = '...' and tablename = '...'; select * from pg_indexes where schemaname = '...' and indexname = '...'; + select + t.relname as table_name, + i.relname as index_name, + a.attname as column_name + from + pg_class t, + pg_class i, + pg_index ix, + pg_attribute a + where + t.oid = ix.indrelid + and i.oid = ix.indexrelid + and a.attrelid = t.oid + and a.attnum = ANY(ix.indkey) + and t.relkind = 'r' + and t.relname like 'test%' + order by + t.relname, + i.relname; + + select + t.relname as table_name, + i.relname as index_name, + array_to_string(array_agg(a.attname), ', ') as column_names + from + pg_class t, + pg_class i, + pg_index ix, + pg_attribute a + where + t.oid = ix.indrelid + and i.oid = ix.indexrelid + and a.attrelid = t.oid + and a.attnum = ANY(ix.indkey) + and t.relkind = 'r' + and t.relname like 'test%' + group by + t.relname, + i.relname + order by + t.relname, + i.relname; + List functions:: \df