Re: Database creation

From: Jeff Eckermann <jeff_eckermann(at)yahoo(dot)com>
To: Marcel Wolf <mwolfs(at)comcast(dot)net>, pgsql-novice(at)postgresql(dot)org
Subject: Re: Database creation
Date: 2004-01-26 20:53:22
Message-ID: 20040126205322.65177.qmail@web20812.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

--- Marcel Wolf <mwolfs(at)comcast(dot)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/

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message April Carvalho 2004-01-26 21:30:54 Re: Problem with pg_hba.conf file in Postgres 7.3
Previous Message Bruno LEVEQUE 2004-01-26 20:49:43 Re: Database creation