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

  1. Launch the psql tool
  2. Enter account information to log into the PostgreSQL database server, if prompted
  3. Enter the following command to create a new database CREATE DATABASE adventureworks;
  4. Open a new terminal window (not in psql) and navigate to the folder where the adventureworks.sql file is located. Use the cd command in the terminal, followed by the file path to change directories to the location of adventureworks.sql. For example: cd /Users/username/Documents/adventureworks.
  5. 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