Thread: test the existence of a database
After a database is created in postgresql using the createdb command, and populate it with some taqbles, how do we test the existence of the database and the tables within it? thanks d'laila
D'laila, you could write a function in plpgsql that queried the postgres catalogues for the object that you were interested in an returned true of false if the object existed. For an example see: http://www.brasileiro.net/postgres/cookbook/view-one-recipe.adp?recipe_id=14 23 hih steve boyle ----- Original Message ----- From: "D'laila Pereira" <dpereira@students.uiuc.edu> To: <pgsql-sql@postgresql.org> Sent: Thursday, January 31, 2002 8:52 PM Subject: [SQL] test the existence of a database > > After a database is created in postgresql using the createdb command, > and populate it with some taqbles, how do we test the existence of the > database and the tables within it? > > thanks > d'laila > > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org >
Hello, I do not see wat u r trying to mean? Do you want to test the existence of a database from your code or from the standard shell? If you want to test from your code, you can try connectingto that database and if your connection is null, that means there might be no database present. Erle > > After a database is created in postgresql using the createdb command, > and populate it with some taqbles, how do we test the existence of the > database and the tables within it? > > thanks > d'laila > > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org >
On Tue, 26 Feb 2002, Erle Czar Mantos wrote: > I do not see wat u r trying to mean? Do you want to test the > existence of a database from your code or from the standard shell? > If you want to test from your code, you can try connecting to > that database and if your connection is null, that means there > might be no database present. alternatively, you can connect to template1 dans do a : SELECT * FROM pg_database; hth. Jerome Alet - alet@unice.fr - http://cortex.unice.fr/~jerome Fac de Medecine de Nice http://wwwmed.unice.fr Tel: (+33) 4 93 37 76 30 Fax: (+33) 4 93 53 15 15 28 Avenue de Valombrose - 06107 NICE Cedex 2 - FRANCE