Last active
April 1, 2024 18:52
-
-
Save jahe/23a8b3378e8695493612654c2ab65ecc to your computer and use it in GitHub Desktop.
psql Cheatsheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Start psql | |
> psql | |
<current-database>=# | |
# Exit psql | |
\q | |
# Show all tables | |
\dt | |
# Show all roles | |
\du | |
# Show all databases | |
\l | |
# Create new database using createdb (not within psql shell) | |
> createdb <database> | |
# Switch to a different database | |
\c <database> | |
# Execute SQL statements | |
<current-database>=# SELECT * FROM product; | |
# Login with role and connect to specific database | |
> psql -U <role> -d <database> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment