Materials

Inserting Data Using \i Command

Step 1: Download File from Resources
For Mac and Windows: Save the file anywhere on your computer and copy the path
For Linux: Save the file in a /home/<your_username>/tmp folder inside your home directory. Create this folder if it doesn’t exist and copy the path.
Step 2: Log into PostgreSQL:
Enter the following command to access PostgreSQL:
psql -U postgres
Step 3: Create the northwind Database:
Once in the PostgreSQL command line, create a new database named northwind:
CREATE DATABASE northwind;
Step 4: Connect to the northwind Database:
Now, switch to the northwind database using:
\c northwind

Step 5: Load Data into PostgreSQL Using the \i Command

Use the \i Command with the File Path:
While connected to the northwind database in PostgreSQL, load the SQL file using the copied path.
For Mac and Windows: \i <file_path>
For Linux:\i /home/<your_usename>/tmp/<file_name>
Verify Data Loaded Successfully:
List tables with \dt to confirm that tables have been created.
Check data in a specific table, such as products, with:
SELECT * FROM products;

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.