0
0
PostgreSQLquery~30 mins

psql command-line tool basics in PostgreSQL - Mini Project: Build & Apply

Choose your learning style9 modes available
psql Command-Line Tool Basics
📖 Scenario: You are a new database administrator for a small company. You need to learn how to use the psql command-line tool to interact with a PostgreSQL database. This will help you manage data and run queries efficiently.
🎯 Goal: Learn the basic commands to connect to a PostgreSQL database using psql, list tables, describe table structure, and run simple SQL queries.
📋 What You'll Learn
Connect to a PostgreSQL database using psql with a database name
List all tables in the connected database using a psql command
Describe the structure of a specific table using a psql command
Run a simple SQL query to select data from a table
💡 Why This Matters
🌍 Real World
Database administrators and developers use psql to manage PostgreSQL databases efficiently from the command line.
💼 Career
Knowing psql commands is essential for database management, troubleshooting, and running queries in many IT and data roles.
Progress0 / 4 steps
1
Connect to the PostgreSQL database
Use the psql command to connect to a PostgreSQL database named company_db. Write the exact command to connect.
PostgreSQL
Need a hint?

Use psql followed by the database name to connect.

2
List all tables in the database
After connecting to company_db, use the psql meta-command to list all tables in the current database. Write the exact command starting with a backslash.
PostgreSQL
Need a hint?

Use \dt to list tables in psql.

3
Describe the structure of a table
Use the psql meta-command to describe the structure of the table named employees. Write the exact command starting with a backslash.
PostgreSQL
Need a hint?

Use \d employees to see the table structure.

4
Run a simple SQL query
Write a SQL query to select all columns from the employees table. End the query with a semicolon.
PostgreSQL
Need a hint?

Use SELECT * FROM employees; to get all data from the table.