One of my recent tasks was the migration of a small spring boot web service to openshift. The webservice works with a postgres which runs in an openshift pod. I had to migrate the database as well.
The psql CLI Tool came in very handy with working with the database. I could get stuff done quickly and work directly on the openshift pods.
Here are my Notes on the psql Tool:
From the shell:
While running the tool:
psql <database name> [--User <username>]
psql TESTDB --User testuser
From the command line:
psql <database name> [--User <username> -c <command> psql <database name> [--User <Username>] -f <Filename>
From the running psql tool you can just write your sql statements:
postgres=#select * from TESTTABLE;
Besides the SQL Drop Database Statement postgres offers another cli utility: dropdb
dropdb <connection parameters> <options> <database name>
To backup data the pg_dump tool might come in handy. The pattern for it is the following:
pg_dump --table=<tablename> --data-only --column-inserts <databasename>