PostgreSQL13に作成済みのロールの一覧を取得する

環境
Windows 10 64bit
PostgreSQL 13

使用例
1.システムカタログから作成済みのロール一覧を取得する

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
testdb=# select rolname, rolsuper, rolcanlogin from pg_roles;
rolname | rolsuper | rolcanlogin
---------------------------+----------+-------------
pg_monitor | f | f
pg_read_all_settings | f | f
pg_read_all_stats | f | f
pg_stat_scan_tables | f | f
pg_read_server_files | f | f
pg_write_server_files | f | f
pg_execute_server_program | f | f
pg_signal_backend | f | f
postgres | t | t
arkgame | f | t
ark00 | f | t
testuser | f | t
test01 | f | t
(13)
testdb=# select rolname, rolsuper, rolcanlogin from pg_roles; rolname | rolsuper | rolcanlogin ---------------------------+----------+------------- pg_monitor | f | f pg_read_all_settings | f | f pg_read_all_stats | f | f pg_stat_scan_tables | f | f pg_read_server_files | f | f pg_write_server_files | f | f pg_execute_server_program | f | f pg_signal_backend | f | f postgres | t | t arkgame | f | t ark00 | f | t testuser | f | t test01 | f | t (13 行)
testdb=# select rolname, rolsuper, rolcanlogin from pg_roles;
          rolname          | rolsuper | rolcanlogin
---------------------------+----------+-------------
 pg_monitor                | f        | f
 pg_read_all_settings      | f        | f
 pg_read_all_stats         | f        | f
 pg_stat_scan_tables       | f        | f
 pg_read_server_files      | f        | f
 pg_write_server_files     | f        | f
 pg_execute_server_program | f        | f
 pg_signal_backend         | f        | f
 postgres                  | t        | t
 arkgame                   | f        | t
 ark00                     | f        | t
 testuser                  | f        | t
 test01                    | f        | t
(13 行)

2.デフォルトロール以外のロールの一覧を表示します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
testdb=# select rolname, rolsuper, rolcanlogin from pg_roles where rolname not like 'pg_%';
rolname | rolsuper | rolcanlogin
----------+----------+-------------
postgres | t | t
arkgame | f | t
ark00 | f | t
testuser | f | t
test01 | f | t
(5)
testdb=# select rolname, rolsuper, rolcanlogin from pg_roles where rolname not like 'pg_%'; rolname | rolsuper | rolcanlogin ----------+----------+------------- postgres | t | t arkgame | f | t ark00 | f | t testuser | f | t test01 | f | t (5 行)
testdb=# select rolname, rolsuper, rolcanlogin from pg_roles where rolname not like 'pg_%';
 rolname  | rolsuper | rolcanlogin
----------+----------+-------------
 postgres | t        | t
 arkgame  | f        | t
 ark00    | f        | t
 testuser | f        | t
 test01   | f        | t
(5 行)

 

PostgreSQL

Posted by arkgame