Loading the Sample Datasets – macOS
Most exercises in this book use a sample database, sqlda
, which contains fabricated data for a fictional electric vehicle company called ZoomZoom. Now, set it up by performing the following steps:
- Enter the PostgreSQL shell by typing the following command in Terminal. Press the return key to execute it:
psql postgres
- Now, create a new database called
sqlda
by typing the following command and pressing return (do not forget the semicolon at the end):create database sqlda;
- You should see the following output. Type
\l
(a backslash followed by lowercase L) in Terminal and press the return key to check whether the database was successfully created (you should see thesqlda
database listed there):
- Type or paste
\q
in the PostgreSQL shell and press the return key to exit. - Download the
data.dump
file from theDatasets
folder in the GitHub repository of this book at https://packt.link/GuU31. Navigate to the folder where you have downloaded the file using thecd
command. Then, type the following command:psql sqlda < ~/Downloads/data.dump
Note
The preceding command assumes that the file is saved in the
Downloads
directory. Make sure you change the highlighted path based on the location of thedata.dump
file on your system. - Then, wait for the dataset to be imported:
- To test if the dataset was imported correctly, type
psql postgres
and then press the return key to enter the PostgreSQL shell again. Then, run\c sqlda
followed by\dt
to see the list of tables within the database: