Обсуждение: Getting a Database List
I need to know the interactive SQL syntax to get a listing of databases on the current server. Using Informix, the commands would be: database sysmaster; select name from sysdatabases; MySQL: show databases; MS-SQL: SELECT name FROM master..sysdatabases ORDER BY name Please reply by posting to this newsgroup. My email address is hashed to protect me from spamming. Thanks, Lee
You can use \l Which is just an alias for the query: SELECT d.datname as "Name", u.usename as "Owner" FROM pg_database d LEFT JOIN pg_user u ON d.datdba = u.usesysid ORDER BY 1; (in case you prefer to do the actual query) Terry Fielder Network Engineer Great Gulf Homes / Ashton Woods Homes terry@greatgulfhomes.com > -----Original Message----- > From: pgsql-general-owner@postgresql.org > [mailto:pgsql-general-owner@postgresql.org]On Behalf Of Lee > Sent: Wednesday, July 24, 2002 10:55 PM > To: pgsql-general@postgresql.org > Subject: [GENERAL] Getting a Database List > > > I need to know the interactive SQL syntax to get a listing of > databases on > the current server. > > Using Informix, the commands would be: > database sysmaster; > select name from sysdatabases; > > MySQL: > show databases; > > MS-SQL: > SELECT name FROM master..sysdatabases ORDER BY name > > Please reply by posting to this newsgroup. My email address > is hashed to > protect me from spamming. > > Thanks, > Lee > > > > > ---------------------------(end of > broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster >
On Thu, Jul 25, 2002 at 10:55:04AM +0800, Lee wrote: > I need to know the interactive SQL syntax to get a listing of databases on > the current server. psql -l select * from pg_database; (IIRC) > Using Informix, the commands would be: > database sysmaster; > select name from sysdatabases; > > MySQL: > show databases; > > MS-SQL: > SELECT name FROM master..sysdatabases ORDER BY name > > Please reply by posting to this newsgroup. My email address is hashed to > protect me from spamming. -- Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/ > There are 10 kinds of people in the world, those that can do binary > arithmetic and those that can't.
Lee wrote: > I need to know the interactive SQL syntax to get a listing of databases on > the current server. select * from pg_database; while in psql you can do \dS (i believe) to get a list of system tables and views. Tom Jenkins
Lee a écrit: > I need to know the interactive SQL syntax to get a listing of databases on > the current server. > > Using Informix, the commands would be: > database sysmaster; > select name from sysdatabases; > > MySQL: > show databases; > > MS-SQL: > SELECT name FROM master..sysdatabases ORDER BY name shell$ psql -E databasename user$ \l