IMHO, listing databases is not well-defined in a cross-RDBMS context, since the definition of database largely differs between RDBMS products. As an example, "database" even has different definitions between Db2 for Linux/Unix/Windows on the one hand, and Db2 for z/OS on the other hand!
What should be well-defined, and maybe that's what you want, is listing schema names. For some RDBMS (e.g. MySQL) schemas coincode with databases. On most platforms they coincode with users. But the definition of a schema is clear: it's the (explicit) table prefix (dot-separated) you need to specify when referring tables in an other than your default schema. As some answers were suggesting, just look at the list of tables (information_schema.tables or the like) and return the distinct values from the column called schema (or user or creator or the like). Your example with PostgreSQL seems to suggest that your definition of database is the "connection entity"; but listing all "connection entities" is intrinsically impossible since you first need to connect (to a database) before you can start asking it for the objects it knows, and by definition it only knows about itself ... -- Peter Vanroose, ABIS Training & Consulting, Leuven, Belgium. On 16 november 2018 03:09 Daniel Kasak <<d.j.kasak...@gmail.com>> wrote: > [... ] > I've done quite a bit of search, but can't find any docs that mention > fetching *databases* - either in ODBC docs or in Perl/DBI docs. The closest > I've found that *might* have worked was DBI's tables() method: > <https://metacpan.org/pod/DBI#tables> > > ... but: > - this doesn't work in cases where there is a separation between hierarchies > at the database level ( eg postgres only lists schemas and tables in the > current database ) >