Load PostgreSQL sample database dvdrental

PostgreSQL sample database that can used for learning and practice PostgreSQL. We will use the DVD rental database for demonstrating the features of PostgreSQL. The DVD rental database has many objects including: 15 tables,one trigger,7 views, 8 functions, one domain and 13 sequences.

Follow below steps to load(install) PostgreSQL sample database dvdrental.

1. Download the PostgreSQL database from http://k2schools.com/wp-content/uploads/2017/12/dvdrental.zip

2. Open command prompt and run the below commands.

C:\>mkdir dvdrental
C:\>cd dvdrental
C:\dvdrental>initdb dvdrentaldb

3. Run the following command, enter the password for user user ‘postgres’
C:\dvdrental>pg_restore -U postgres -d dvdrental dvdrental.tar
Password:

4. Verification: Run \l to navigate to dvdrental database

dvdrental=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+----------------------------+----------------------------+----------------------- company | k2admin | UTF8 | English_United States.1252 | English_United States.1252 | dvdrental | postgres | UTF8 | English_United States.1252 | English_United States.1252 | postgres | postgres | UTF8 | English_United States.1252 | English_United States.1252 | template0 | postgres | UTF8 | English_United States.1252 | English_United States.1252 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | English_United States.1252 | English_United States.1252 | =c/postgres + | | | | | postgres=CTc/postgres (5 rows)

\d to get list objects in the dvdrental database.

dvdrental=# \d

List of relations Schema | Name | Type | Owner --------+----------------------------+----------+---------- public | actor | table | postgres public | actor_actor_id_seq | sequence | postgres public | actor_info | view | postgres public | address | table | postgres public | address_address_id_seq | sequence | postgres public | category | table | postgres public | category_category_id_seq | sequence | postgres public | city | table | postgres public | city_city_id_seq | sequence | postgres public | country | table | postgres

Responses are currently closed, but you can trackback from your own site.

Comments are closed.

Powered by k2schools
%d bloggers like this: