Thread: Database creation
I would like my application to start up and see if the database is there if not create it. I am not sure how to do it. When I try and query my database I get a fatal error and it won’t accept my Create db command. Also I am converting from mysql and my table field names are a mixture of capitals and small letters. When these strings are passed to the database they are always changed to lowercase?
Thanks for the help
Marcel
Hi, if you want known the existence or not of of database, you can use a query like : select * from pg_database Bruno On Mon, 26 Jan 2004, Marcel Wolf wrote: > I would like my application to start up and see if the database is there > if not create it. I am not sure how to do it. When I try and query my > database I get a fatal error and it won't accept my Create db command. > Also I am converting from mysql and my table field names are a mixture > of capitals and small letters. When these strings are passed to the > database they are always changed to lowercase? > > Thanks for the help > Marcel > > Bruno LEVEQUE System Engineer SARL NET6D bruno.leveque@net6d.com http://www.net6d.com
--- Marcel Wolf <mwolfs@comcast.net> wrote: > I would like my application to start up and see if > the database is there > if not create it. I am not sure how to do it. When I > try and query my > database I get a fatal error and it won't accept my > Create db command. Try connecting first of all to the "template1" database, which will always be there in any PostgreSQL install. Then you can query the system catalogs to find out whether the database you are looking for exists or not, and create the database from there if not (note that any other session trying to create a database will be unable to do so while you are connected to template1, because template1 is used as the template for all new databases). > Also I am converting from mysql and my table field > names are a mixture > of capitals and small letters. When these strings > are passed to the > database they are always changed to lowercase? The SQL standard specifies that identifiers (names for tables, columns etc.) be non-case-sensitive. In PostgreSQL this is implemented by downcasing all identifiers in SQL statements. You can get around this by double-quoting all identifier names that contain mixed case letters (some client applications do this by default). You will probably find it easier to just go with the flow, and change them all to lower case. > > Thanks for the help > Marcel > > __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/