CSCI 338: Fall 2023

Software Engineering

CSCI 338: Fall 2023

Schedule > 9. Databases and Object Relational Mappings

Tue, Oct 31

Readings & References

PostgreSQL Reference

SQLAlchemy Reference

PostgreSQL Administrative Commands

To enter the postgreSQL shell, type: psql -U postgres (connecting as the postgres superuser). Once you’re in the psql shell, try using the following commands:

Command Explanation Example
\q Exits the psql shell  
\l Lists all the available databases  
\c <dbname> <username> Connect to specific database \c photo_app_tutorial postgres
\dt Lists all of the tables in the database you’re connected to  
\d <table_name> Describes the structure (i.e., “schema”) of a table \d posts
\du List all users and their roles  
space bar If you query data in a table that has multiple pages, the space bar will show you the next set of records.  
q If you query data in a table that has multiple pages, and you want to go back to the psql prompt.  

Slides

Activities