Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieve / Read Database Names

Status
Not open for further replies.

TLowder

Programmer
Mar 20, 2002
224
0
0
This has to be simple but I've never done this. I would like to return a list of database names from PostgreSQL, MySQL and perhaps others. Maybe this is more a sql or database specific question, but search subject lines is gone and I can't figure out what I should search for. Anyway, I've always created a connection to the database with the database name. Perhaps there is there a way to connect to the database without a specific name, then return the names? With MySQL I could just read the folder names in the data dir but PostgreSQL is different. I would like to be able to connect without a database name then use a sql statement to return the values. I bet this is easy, but when I search for what I want too many results are returned.

Thanks,


Tom
 
I figured it out.

MySQL = "show databases"
PostgreSQL = "select datname from pg_database"

Thanks,

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top