|Problems? Is your data what you think it is?|
Re: DBI:how to get name of the db ?by erix (Vicar)
|on Dec 14, 2011 at 09:22 UTC||Need Help??|
For the sake of completeness: SQL-standard compliant databases have table information_schema_catalog_name, which always contains one row and one column containing the name of the current database (the current 'catalog', in SQL terminology).
(The SQL standard says "The value of CATALOG_NAME is the name of the catalog in which this Information Schema resides.")
I'd normally prefer DBI, but the SQL can be handy.
(And FWIW: postgres also supports the more succinct and standard-compliant CURRENT_CATALOG:)
And then there is DBI's get_info stuff:
update: Jenda: Re SQL-standard versions: PostgreSQL supports generally quite recent versions: SQL:2011 and SQL:2008. And even SQL92 already prescribed INFORMATION_SCHEMA_CATALOG_NAME.
Some systems are more SQL-compliant than others. PostgreSQL tries quite hard to implement as much as possible.