Postgresql로 작업할 때마다 스키마 생성부터 계속 반복적으로 검색하는 경우가 잦아 이제 나를 위해 몇 개 내용을 공부겸 나중을 위해 작성해봄.
[root@server ~] psql -U postgres
psql (버전)
Type "help" for help.
postgres=#
postgres=# \l
Name | Owner | Encoding | Collate | Ctype | Access privileg
es
-----------+----------+----------+-------------+-------------+------------------
-----
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
| | | | | postgres=CTc/postgres
postgres=# \c [db name]
You are now connected to database "[db name]" as user "postres".
db_name=#
CREATE DATABASE [db name];
CREATE DATABASE [db name] OWNER [user name];
ALTER DATABASE [db name] OWNER TO [user name];
SELECT * FROM PG_USER;
usename | usesysid | usecreatedb | usesuper | userepl | usebypassrls | passwd | valuntil | useconfig
----------+----------+-------------+----------+---------+--------------+----------+----------+-----------
postgres | 10 | t | t | t | t | ******** | |
postgres=# \du
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
DROP ROLE [user name];
CREATE USER [user name] PASSWORD 'password';
ALTER ROLE [user name] LOGIN password 'passwrd';
db_name=# \dn
List of schemas
Name | Owner
--------+----------
public | postgres
(1 rows)
CREATE SCHEMA [schema name] AUTHORIZATION [user name];