Installing the Sample Database

If you want, you can download a sample database from this book's web site:

After you have downloaded the bookdata.tar.gz file, you can unpack it with either of the following commands:

$ tar ?zxvf bookdata.tar.gz


$ gunzip ?c bookdata.tar.gz | tar ?xvf ?

The bookdata.tar.gz file contains a number of files and will unpack into your current directory. After unpacking, you will see a subdirectory for each chapter (okay, for most chapters?not all chapters include sample code or sample data).

You can use the chapter1/load_sample.sql file to create and populate the three tables that I have discussed (tapes, customers, and rentals). To use the load_sample.sql file, execute the following command:

$ psql ?d movies ?f chapter1/load_sample.sql

This command drops the tapes, customers, and rentals tables (if they exist), creates them, and adds a few sample rows to each one.

    Part II: Programming with PostgreSQL