What i want to do is to make a drop down list of all the databases of my postgresql 9.3 server using php . if i can get just the sql script that can do the trick then i can handle the php part.
Thanks for your time.
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.Sign up to join this community
This information is stored in
select datname from pg_database;
Obviously you need to connect some database in order to be able to run the query.
SELECT pg_database.datname as "Database", pg_user.usename as "postgres" FROM pg_database, pg_user WHERE pg_database.datdba = pg_user.usesysid UNION SELECT pg_database.datname as "Database", NULL as "postgres" FROM pg_database WHERE pg_database.datdba NOT IN (SELECT usesysid FROM pg_user) ORDER BY "Database" -- database that belong to user postgres SELECT pg_database.datname as "Database" FROM pg_database; -- all databases SELECT datname FROM pg_database WHERE datistemplate = false;