dbTalk Databases Forums  

Database creation

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss Database creation in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Marcel Wolf
 
Posts: n/a

Default Database creation - 01-26-2004 , 02:37 PM






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



Reply With Quote
  #2  
Old   
Bruno LEVEQUE
 
Posts: n/a

Default Re: Database creation - 01-26-2004 , 02:49 PM






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:

Quote:
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 (AT) net6d (DOT) com
http://www.net6d.com

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend



Reply With Quote
  #3  
Old   
Jeff Eckermann
 
Posts: n/a

Default Re: Database creation - 01-26-2004 , 02:53 PM



--- Marcel Wolf <mwolfs (AT) comcast (DOT) net> wrote:
Quote:
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).

Quote:
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.
Quote:
Thanks for the help
Marcel



__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo (AT) postgresql (DOT) org



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.