본문 바로가기
데이타베이스

[postgres] postgres 데이터베이스 명령어

by hs_seo 2020. 9. 13.

postgres의 명령어를 알아보겠습니다.

사용자 목록 조회: \du

postgres=# \du
                                   List of roles
 Role name |                         Attributes                         | Member of 
-----------+------------------------------------------------------------+-----------
 a         |                                                            | {}
 h         |                                                            | {}
 o         |                                                            | {}
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}

데이터 베이스 목록 조회: \l

postgres=# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges    
-----------+----------+----------+-------------+-------------+------------------------
 a         | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =Tc/postgres          +
           |          |          |             |             | postgres=CTc/postgres +
           |          |          |             |             | a     =CTc/postgres
 (1 rows)

테이블 목록 조회: \dt

a     =# \dt
                    List of relations
 Schema |             Name              | Type  | Owner  
--------+-------------------------------+-------+--------
 public | adminpermission               | table | a     
 public | adminprincipal                | table | a     

테이블 칼럼 정보 확인: \d

oozie=> \d wf_jobs
                              Table "public.wf_jobs"
       Column       |            Type             | Collation | Nullable | Default 
--------------------+-----------------------------+-----------+----------+---------
 id                 | character varying(255)      |           | not null | 
 app_name           | character varying(255)      |           |          | 
 app_path           | character varying(255)      |           |          | 
 conf               | bytea                       |           |          | 
 created_time       | timestamp without time zone |           |          | 
 end_time           | timestamp without time zone |           |          | 
 external_id        | character varying(255)      |           |          | 
 group_name         | character varying(255)      |           |          | 
 last_modified_time | timestamp without time zone |           |          | 
 log_token          | character varying(255)      |           |          | 
 parent_id          | character varying(255)      |           |          | 
 proto_action_conf  | bytea                       |           |          | 
 run                | integer                     |           |          | 
 sla_xml            | bytea                       |           |          | 
 start_time         | timestamp without time zone |           |          | 
 status             | character varying(255)      |           |          | 
 user_name          | character varying(255)      |           |          | 
 wf_instance        | bytea                       |           |          | 
Indexes:
    "wf_jobs_pkey" PRIMARY KEY, btree (id)
    "i_wf_jobs_end_time" btree (end_time)
    "i_wf_jobs_external_id" btree (external_id)
    "i_wf_jobs_last_modified_time" btree (last_modified_time)
    "i_wf_jobs_parent_id" btree (parent_id)
    "i_wf_jobs_status" btree (status)
반응형