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
sqldaby 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 thesqldadatabase listed there):
Figure 0.30: Checking whether a new database is successfully created
- Type or paste
\qin the PostgreSQL shell and press the return key to exit. - Download the
data.dumpfile from theDatasetsfolder in the GitHub repository of this book at https://packt.link/GuU31. Navigate to the folder where you have downloaded the file using thecdcommand. Then, type the following command:psql sqlda < ~/Downloads/data.dump
Note
The preceding command assumes that the file is saved in the
Downloadsdirectory. Make sure you change the highlighted path based on the location of thedata.dumpfile on your system. - Then, wait for the dataset to be imported:
Figure 0.31: Importing the dataset
- To test if the dataset was imported correctly, type
psql postgresand then press the return key to enter the PostgreSQL shell again. Then, run\c sqldafollowed by\dtto see the list of tables within the database:
Figure 0.32: List of tables within the sqlda database