Last active
January 28, 2016 23:15
-
-
Save jmccaffrey/7568851 to your computer and use it in GitHub Desktop.
Thinkful Unit 2 Lesson 4 instructions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
in Step 2 you download a file called dvdrental.zip | |
It might not be clear that you need to also do | |
'createuser -s postgres' | |
and | |
psql -U postgres | |
CREATE DATABASE dvdrental; | |
Step 3: 'Type the following command: unzip dvdrental.tar' should say 'unzip dvdrental.zip' | |
Step 4: pg_restore -U postgres -d dvdrental dvdrental.tar | |
the original instruction was "pg_restore -U postgres -d dvdrental .dvdrental.tar" | |
you can't use '.dvdrental.tar' with that leading '.' | |
at the end of that step it mentions "If you about the role postgres not existing" | |
it probably means "If you get an ERROR" | |
if you didn't create the user, you also might not have created the database either | |
and will get errors about that | |
Quick way to confirm that it all worked | |
psql -U postgres | |
help | |
# that will show you how to get some basic help | |
# \? will give you psql specific help | |
# now connect to the dvdrental db | |
\c dvdrental | |
# see the names of the tables under this db | |
\dt | |
# verify that the data has loaded | |
select count(*) from actor ; | |
# will return a count of 200 | |
count | |
------- | |
200 | |
(1 row) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from http://www.thinkful.com/courses/ROR-001/unit/2/lesson/4 | |
1. First, read through all four pages of this introduction to relational databases. You don't need to spend a lot of time on this article, but you should try to get a basic sense of how relational databases work. | |
2. Now you'll need to download the sample database. Go to this link and read the notes on the database and then download the file from the link towards the bottom of the page. | |
3. After the file has downloaded, from the command line, navigate to the folder the file is in and run the following command to unzip the .zip file you downloaded into a .tar file (one of the file formats you can use for restoring Postgres backups). Type the following command: unzip dvdrental.tar. There should now be a file called dvdrental.tar in this directory. | |
4. Now you'll need to use the pg_restore command to restore the database. From the command line, enter the following command: pg_restore -U postgres -d dvdrental .dvdrental.tar. If you about the role postgres not existing, you'll need to create a superuser called "postgres". To do this, run the following command: createuser -s postgres, and then rerun pg_restore -U postgres -d dvdrental .dvdrental.tar. | |
5. Now let's verify that your restoration was successful. From the command line, type psql to open the PostgresSQL command line console. Inside psql, enter the following command: \list . If your restoration was successful, you will see "dvdrental" in the list of databases. You can exit psql by entering the command \q . | |
6. Now it's time to play with the data(base). Work through the following exercises from postgresqltutorial.com (and be sure to actually type out the examples as you go through the exercises!): | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment