I know I can list my postgres databases with the following command:
# list only the databases
psql -U openerp -q -t -c "select datname from pg_database;" template1
Or
# show a full listing of databases
psql template1 -U openerp -l
How can I filter the databases by owner 'openerp'? datdba
field is just a number… how can I map it?
Best Answer
For things like this, you'll want to query
pg_database
directly. Theowner
field is a reference topg_catalog.pg_authid.oid
, but this is a superuser-only accessible table. There's a view,pg_catalog.pg_roles
that exposes the id as theoid
attribute, so you can: