To enter the Postgres command line, you need to be the dspace user (sudo su - dspace). The command is psql. Here is a link to the database diagram for DSpace 5.
It sometimes may be quicker to use the REST API than creating a complicated query. And the JRuby DSpace wrapper (documentation) may be simpler as well.
Useful commands:
\dt: describe all tables\d {TABLE}: describe the given table\copy ({query}) to '{filename}' as CSV HEADER: saves the query to a CSV with a header