Restoring DVD rental database into postgresql

Get postgresql ready:

Now make sure you have a postgresql installed and running. If you need help please visit my blog: https://aichamp.wordpress.com/2017/03/20/setup-postgresql-database-on-osx/

Get the DVD Rental database:

Next, please download DVD Rental Sample Database from the link below:

http://www.postgresqltutorial.com/postgresql-sample-database/#

Note: The database file is in zipformat ( dvdrental.zip) so you need to extract it to  dvdrental.tar. You dont need to untar it, just keep the .tar file.

 

Environment:

$ pwd

/Users/avkashchauhan/tools/postgres

$ mkdir dvdrentaldb

$ initdb dvdrentaldb

Make sure the database dvdrentaldb is initialize and fully ready with username avkash.

Restore the Database:

$ pg_restore -U avkash -d dvdrentaldb dvdrental.tar

Now verify the database:

$ psql -U avkash dvdrentaldb

You will have access to postgresql shell and then you can run command as below:

psql (9.6.2)
Type "help" for help.

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

Thats all, enjoy!!

 

Advertisements

One thought on “Restoring DVD rental database into postgresql

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s