Skip to content

tomioka-k/postgresql-docker-practice-environment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker-composeの実行

$ docker-compose build
$ docker-compose up

postgrsqlへ入る

$ docker exec -it postgres bash

shellへ入ったらpsqlで入ります。

# psql -U admin

サンプルデータの準備

https://www.postgresqltutorial.com/postgresql-getting-started/postgresql-sample-database/

  1. dvdrentalのデータベースを作成
  2. sample/dvdrental.tarを取り込む

の手順で、サンプルデータを準備します。

CREATE DATABASE dvdrental

データベースを作成し

$ pg_restore -U admin -d dvdrental /var/lib/postgresql/data/sample-db/dvdrental.tar

pg_restoreでデータを読み込み

https://www.postgresql.jp/docs/9.0/app-pgrestore.html

\c dvdrental

\cdvdrentalデータベースに移動、\dtでテーブルを確認

dvdrental=# \dt
           List of relations
 Schema |     Name      | Type  | Owner
--------+---------------+-------+-------
 public | actor         | table | admin
 public | address       | table | admin
 public | category      | table | admin
 public | city          | table | admin
 public | country       | table | admin
 public | customer      | table | admin
 public | film          | table | admin
 public | film_actor    | table | admin
 public | film_category | table | admin
 public | inventory     | table | admin
 public | language      | table | admin
 public | payment       | table | admin
 public | rental        | table | admin
 public | staff         | table | admin
 public | store         | table | admin
(15 rows)

About

postgresql docker practice environment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published