1. 데이터베이스 목록 조회
postgres=# select datname from pg_database;
datname
-----------
postgres
template1
template0
dvdrental
(4개 행)
postgres=# \l
데이터베이스 목록
이름 | 소유주 | 인코딩 | Collate | Ctype | 액세스 권한
-----------+----------+--------+------------------+------------------+-----------------------
dvdrental | postgres | UTF8 | Korean_Korea.949 | Korean_Korea.949 |
postgres | postgres | UTF8 | Korean_Korea.949 | Korean_Korea.949 |
template0 | postgres | UTF8 | Korean_Korea.949 | Korean_Korea.949 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | Korean_Korea.949 | Korean_Korea.949 | =c/postgres +
| | | | | postgres=CTc/postgres
(4개 행)
2. 데이터베이스 선택
postgres=# \c dvdrental
접속정보: 데이터베이스="dvdrental", 사용자="postgres".
3. 테이블 목록 조회
dvdrental=# \dt
릴레이션(relation) 목록
스키마 | 이름 | 종류 | 소유주
--------+---------------+--------+----------
public | actor | 테이블 | postgres
public | address | 테이블 | postgres
public | category | 테이블 | postgres
public | city | 테이블 | postgres
public | country | 테이블 | postgres
public | customer | 테이블 | postgres
public | film | 테이블 | postgres
public | film_actor | 테이블 | postgres
public | film_category | 테이블 | postgres
public | inventory | 테이블 | postgres
public | language | 테이블 | postgres
public | payment | 테이블 | postgres
public | rental | 테이블 | postgres
public | staff | 테이블 | postgres
public | store | 테이블 | postgres
(15개 행)
dvdrental=# select * from pg_catalog.pg_tables where schemaname != 'pg_catalog' and schemaname != 'information_schema';
schemaname | tablename | tableowner | tablespace | hasindexes | hasrules | hastriggers | rowsecurity
------------+---------------+------------+------------+------------+----------+-------------+-------------
public | actor | postgres | | t | f | t | f
public | store | postgres | | t | f | t | f
public | address | postgres | | t | f | t | f
public | category | postgres | | t | f | t | f
public | city | postgres | | t | f | t | f
public | country | postgres | | t | f | t | f
public | customer | postgres | | t | f | t | f
public | film_actor | postgres | | t | f | t | f
public | film_category | postgres | | t | f | t | f
public | inventory | postgres | | t | f | t | f
public | language | postgres | | t | f | t | f
public | rental | postgres | | t | f | t | f
public | staff | postgres | | t | f | t | f
public | payment | postgres | | t | f | t | f
public | film | postgres | | t | f | t | f
(15개 행)
'SQL' 카테고리의 다른 글
Python에서 PostgreSQL 연결을 위한 설정 (0) | 2022.05.20 |
---|