List of useful PostgreSQL commands
- 30 Aug 2017: Post was created (diff)
From time to time I come across PostgreSQL databases that I have to interact with. But the command syntax is somewhat different than what I’m used to from other databases like MSSQL or MySQL. This is a collection of commands I use, but often forget.
psql
$ psql -U user -d dbname -c "# SQL command" -f ./script.sql
Commands
Select database
db=# \c databasename
List tables in current database
db=# \dt
Show all available commands
db=# \?
Queries
Change database user password
ALTER USER user_name WITH PASSWORD 'new_password';
If you have any comments or feedback, please send me an e-mail. (stig at stigok dotcom).
Did you find any typos, incorrect information, or have something to add? Then please propose a change to this post.