Yesterday evening someone took a dump of the shop database: the file ~/backup/shop.dump. Today a colleague decided to check that the dump works and restored it straight into shop: the tables are there, so nothing can break.
Repeat the check, then do what the shop does every minute: add an order. You have your own student role in PostgreSQL, with no password needed. “Start” launches the server and prepares the database and the dump.
Restore the dump over the live database
In ~/backup, restore yesterday's dump straight into the shop database, count the orders and add a new one.
First, predict
What will pg_restore do to the shop database?
Now start the exercise, run the command and compare your prediction with the output.
How many orders were left in orders after pg_restore?
-
No duplicates got in: the primary key stopped
COPYwithduplicate key … Key (id)=(1) already exists. -
CREATE TABLEfailed withalready exists: the table is the same one, andcount(*)showed 6. -
count(*)showed 6: pg_restore did not replace any rows, and itsCOPYfailed on the very first id.
All 6 of today's orders stayed in orders because the dump's COPY did not get through.