C Appendix E - Install adventureworks
on your own machine
This appendix demonstrates how to:
- Setup the
adventureworks
database locally on your machine- Connect to the
adventureworks
database- These instructions should be tested by a Windows user
- The PostgreSQL tutorial links do not work, despite being pasted from the site
C.1 Overview
This appendix details the process to download and restore the adventureworks
database so that you can work with the database locally on your own machine. This tutorial assumes that (1) you have PostgreSQL installed on your computer, and (2) that you have configured your system to run psql at the command line. Installation of PostgreSQL and configuration of psql are outside the scope of this book.
C.1.1 Download the adventureworks
database
Download the adventureworks
database from here.
C.1.2 Restore the dvdrental
database at the command line
- Launch the psql tool
- Enter account information to log into the PostgreSQL database server, if prompted
- Enter the following command to create a new database
CREATE DATABASE adventureworks;
- Open a new terminal window (not in psql) and navigate to the folder where the
adventureworks.sql
file is located. Use thecd
command in the terminal, followed by the file path to change directories to the location ofadventureworks.sql
. For example:cd /Users/username/Documents/adventureworks
. - Enter the following command prompt:
pg_restore -d adventureworks -f -U postgres adventureworks.sql
C.1.3 Restore the adventureworks
database using pgAdmin
Another option to restore the adventureworks
database locally on your machine is with the pgAdmin graphical user interface. However, we highly recommend using the command line methods detailed above. Installation and configuration of pgAdmin is outside the scope of this book.
C.2 Resources
Instructions by PostgreSQL Tutorial to load the
dvdrental
database. (PostgreSQL Tutorial Website 2019).Windows installation of PostgreSQL by PostgreSQL Tutorial. (PostgreSQL Tutorial Website 2019).
Installation of PostgreSQL on a Mac using Postgres.app. (Postgres.app 2019).
Command line configuration of PosgreSQL on a Mac with Postgres.app. (Postgres.app 2019).
Installing PostgreSQL for Linux, Arch Linux, Windows, Mac and other operating systems, by Postgres Guide. (Postgres Guide Website 2019).