Re: CREATE DATABASE question.

From: Eric Faulhaber <ecf(at)goldencode(dot)com>
To: Karen Hill <karen_hill22(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: CREATE DATABASE question.
Date: 2006-07-27 00:04:54
Message-ID: 44C80326.5030909@goldencode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Karen Hill wrote:
> I have an sql file that doesn' t work properly when I do: psql <
> mysql.sql . I cannot get it to connect to the database.
>
> Here what I'd like it to do:
>
> CREATE DATABASE testdb;
> \c testdb;
> CREATE TABLE tableTest(var varchar);
>
> But I get an error on the second line about an invalid character. Is
> it even possible to connect to a different db when giving an sql file
> to psql to process?

Sure, just lose the trailing semi-colon from your connect command, as in:

CREATE DATABASE testdb;
\c testdb
CREATE TABLE tableTest(var varchar);

This lets psql interpret your connect request as a psql command instead
of as an SQL statement.

Regards,
Eric Faulhaber

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Aaron Glenn 2006-07-27 01:08:01 Re: Database corruption with Postgre 7.4.2 on FreeBSD 6.1?
Previous Message aurora 2006-07-26 23:51:28 Re: Database corruption with Postgre 7.4.2 on FreeBSD 6.1?