Today at work I had to help a colleague with setting up his postgresql database with psql, with no docker available. Then I realized I had forgotten how to do some basic admin through cli, without using a GUI like pgadmin3 as I am used to. So, here are quick reminders for my future self.
createdb [dbname]dropdb [dbname]createuser --interactive [username]dropuser [username]psql\?: Get a full list of psql commands, including those not listed here.
\l: List databases
\c: Connect to a different database. Follow this by the database name.
\d: List available tables, views, and sequences in current database.
\dt: List tables
\du: List available roles
\dp: List access privileges
\password: Change the password for the username that follows.
\conninfo: Get information about the current database and connection.
\h: Get help on SQL commands. You can follow this with a specific command to get help with the syntax.
\q: Quit the psql program and exit to the Linux prompt.
ALTER USER [username] WITH SUPERUSER;