Thread: Create Database Question

Create Database Question

From
"Greg Quinn"
Date:

I am trying to create a database with a table…

 

i.e

 

create database myNewDb;

 

CREATE TABLE servers (

    serverid character varying(60) NOT NULL,

    companyid character varying(60) NOT NULL,

    servername character varying(50) NOT NULL,

    companyname character varying(50) NOT NULL

) WITHOUT OIDS;

 

Cool. The problem is, if I run this SQL command, from within another database instance, it tries to create the table for that database, and not for the  myNewDb database.

How do I modify the query.

 

I know SQL Server has something like…

 

Using [myNewDb]

 

CREATE TABLE …

Re: Create Database Question

From
"Shoaib Mir"
Date:
After create database add something like:

\c myNewDb

Thanks,
--------
Shoaib Mir
EnterpriseDB ( www.enterprisedb.com)

On 10/27/06, Greg Quinn <greg@officium.co.za> wrote:

I am trying to create a database with a table…

 

i.e

 

create database myNewDb;

 

CREATE TABLE servers (

    serverid character varying(60) NOT NULL,

    companyid character varying(60) NOT NULL,

    servername character varying(50) NOT NULL,

    companyname character varying(50) NOT NULL

) WITHOUT OIDS;

 

Cool. The problem is, if I run this SQL command, from within another database instance, it tries to create the table for that database, and not for the  myNewDb database.

How do I modify the query.

 

I know SQL Server has something like…

 

Using [myNewDb]

 

CREATE TABLE …


Re: Create Database Question

From
norman
Date:
You have to create the database first and then run your newdb.sql

# createdb -U dbuser dbname
CREATE DATABASE
# psql –U dbuser dbname < newdb.sql

Norman


Greg Quinn <greg@officium.co.za> wrote:
I am trying to create a database with a table…
 
i.e
 
create database myNewDb;
 
CREATE TABLE servers (
    serverid character varying(60) NOT NULL,
    companyid character varying(60) NOT NULL,
    servername character varying(50) NOT NULL,
    companyname character varying(50) NOT NULL
) WITHOUT OIDS;
 
Cool. The problem is, if I run this SQL command, from within another database instance, it tries to create the table for that database, and not for the  myNewDb database.
How do I modify the query.
 
I know SQL Server has something like…
 
Using [myNewDb]
 
CREATE TABLE …

Send instant messages to your online friends http://uk.messenger.yahoo.com