Creating a database with psql

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Creating a database with psql

Josef Springer
Hi,

i want to automate the startup of my database. So i have to create first
an user and a database, second the schema, all with psql. But how can i
create a database with psql if no database exist ? Executing psql, i
must define the options for a database and an user with password.

Best Regards,
Josef Springer





---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to [hidden email] so that your
       message can get through to the mailing list cleanly
Reply | Threaded
Open this post in threaded view
|

Re: Creating a database with psql

im i
Hi,

1. connect template1 database with your user.
2. create database YOURDB
3. "\c YOURDB" will connect to new database
4. create table etc.

linimi

On 7/20/05, Josef Springer <[hidden email]> wrote:

> Hi,
>
> i want to automate the startup of my database. So i have to create first
> an user and a database, second the schema, all with psql. But how can i
> create a database with psql if no database exist ? Executing psql, i
> must define the options for a database and an user with password.
>
> Best Regards,
> Josef Springer
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
>        subscribe-nomail command to [hidden email] so that your
>        message can get through to the mailing list cleanly
>

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster
Reply | Threaded
Open this post in threaded view
|

Re: Creating a database with psql

Michael Fuhr
In reply to this post by Josef Springer
On Wed, Jul 20, 2005 at 11:28:23AM +0200, Josef Springer wrote:
> i want to automate the startup of my database. So i have to create first
> an user and a database, second the schema, all with psql. But how can i
> create a database with psql if no database exist ?

When you first install PostgreSQL, you run initdb to initialize a
cluster.  This creates a few default databases and a database
superuser.  Then you start the backend and make connections to it
using psql or some other client.  See the "Server Administration"
part of the documentation for more information:

http://www.postgresql.org/docs/8.0/static/admin.html

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match