We cannot find it directly but we can check attributes of directories which contain data files of each database. In PostgreSQL you can try this query:

with
mydir as (select setting||'/base' as _dir from pg_settings where name = 'data_directory'),
mydbs as (select oid as _oid, datname from pg_database),
myfiles as (select _dir, pg_ls_dir(_dir) as _file from mydir),
details as (select _dir, _file, (select datname from mydbs where _oid::text=_file) as _database,
string_to_array(replace(replace(pg_stat_file(_dir||'/'||_file)::text,'(',''),')',''),',') as _detail from myfiles)
select
_database,
_detail[1]::bigint as _size,
_detail[2]::timestamp as _last_accessed,
_detail[3]::timestamp as _last_modified,
_detail[4]::timestamp as _last_file_status_change_unix_only,
_detail[5]::text as _file_creation_windows_only,
_detail[6]::boolean as _is_directory,
_dir,
_file
from details
order by _database

Or on RedHat/CentOS you can use this one-line-script:


for db in $(psql -U postgres -d postgres -t -c "select oid from pg_database"); do echo "database: "$(psql -U postgres -d postgres -t -c "select datname from pg_database where oid=$db"); ls -dl $(psql -U postgres -d postgres -t -c "show data_directory")"/base/"$db; done