0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PostgresSQL 使い方

0
Posted at

■接続

psql -U postgres

接続(CREATE ROLEで作成したロールで)

psql -U role_sample -d postgras

ポイント:-d postgres でDB名を指定する

■切断

\q

■ユーザー新規作成

CREATE ROLE role_sample WITH LOGIN PASSWORD password;
CREATE ROLE user01 WITH PASSWORD 'pass01'

■ユーザー一覧を表示

\du

ロール名 | 属性 | 所属グループ
-------------+--------------------------------------------------------------------------+--------------
postgres | スーパユーザ, ロール作成可, DB作成可, レプリケーション可, RLS のバイパス | {}
role_sample | | {}

■権限の付与

・role_sampleにpg_shadowテーブルアクセス権限を付与

GRANT SELECT ON pg_shadow TO role_sample;

select * from pg_shadow;

usename | usesysid | usecreatedb | usesuper | userepl | usebypassrls | passwd | valuntil | useconfig
-------------+----------+-------------+----------+---------+--------------+-------------------------------------+----------+-----------
postgres | 10 | t | t | t | t | md53175bce1d3201d16594cebf9d7eb3f9d | |
role_sample | 16393 | f | f | f | f | md566db5a3e78c609bc2f01adcbab20850a | |

・user01にログイン権限を付与

ALTER ROLE user01 LOGIN;

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?