PostgreSQL 를 배우고 실습에 사용할 수 있는 샘플 데이터베이스 생성 방법을 알아보겠습니다.
DVD rental 데이터베이스는 DVD 대여점의 비즈니스 프로세스를 나타냅니다.
아래와 같은 오브젝트를 포함하고 있습니다.
OBJECT & ER Model
아래 zip 파일을 통해 PostgreSQL DVD rental Database 를 다운로드 할 수 있습니다.
다운로드 받은 파일을 서버로 옮긴 후 아래와 같이 수행하여 적용합니다.
# unzip dvdrental.zip
-- 만약 unzip 패키지 설치가 안되어 있다면 ?
-- yum install -y unzip
# chown opensql:opensql dvdrental.tar
# mv dvdrental.tar /opensql/
# su -opensql
$ psql -U postgres -d postgres -c "create database dvdrental;"
$ pg_restore -U postgres -d dvdrental /opensql/dvdrental.tar
JavaScript
복사
오류 없이 수행 하셨다면 DVD rental Database 적용이 끝났습니다.
이제 PostgreSQL에 접속해서 간단하게 확인을 해보겠습니다.
$ psql -U postgres -d dvdrental
psql (14.6)
Type "help" for help.
dvdrental=# \dt
List of relations
Schema | Name | Type | Owner
--------+---------------+-------+----------
public | actor | table | postgres
public | address | table | postgres
public | category | table | postgres
public | city | table | postgres
public | country | table | postgres
public | customer | table | postgres
public | film | table | postgres
public | film_actor | table | postgres
public | film_category | table | postgres
public | inventory | table | postgres
public | language | table | postgres
public | payment | table | postgres
public | rental | table | postgres
public | staff | table | postgres
public | store | table | postgres
(15 rows)
dvdrental=# \ds
List of relations
Schema | Name | Type | Owner
--------+----------------------------+----------+----------
public | actor_actor_id_seq | sequence | postgres
public | address_address_id_seq | sequence | postgres
public | category_category_id_seq | sequence | postgres
public | city_city_id_seq | sequence | postgres
public | country_country_id_seq | sequence | postgres
public | customer_customer_id_seq | sequence | postgres
public | film_film_id_seq | sequence | postgres
public | inventory_inventory_id_seq | sequence | postgres
public | language_language_id_seq | sequence | postgres
public | payment_payment_id_seq | sequence | postgres
public | rental_rental_id_seq | sequence | postgres
public | staff_staff_id_seq | sequence | postgres
public | store_store_id_seq | sequence | postgres
(13 rows)
dvdrental=# \dv
List of relations
Schema | Name | Type | Owner
--------+----------------------------+------+----------
public | actor_info | view | postgres
public | customer_list | view | postgres
public | film_list | view | postgres
public | nicer_but_slower_film_list | view | postgres
public | sales_by_film_category | view | postgres
public | sales_by_store | view | postgres
public | staff_list | view | postgres
(7 rows)
JavaScript
복사
지금까지 PostgreSQL Sample Database에 관해 알아보았습니다
PostgreSQL을 쉽게 사용할 수 있도록 유용한 팁을 가지고 돌아오겠습니다.
다음 컨텐츠도 기대해주세요! (컨텐츠는 매주 업데이트 됩니다.)