Обсуждение: SQL-commands does not work

Поиск
Список
Период
Сортировка

SQL-commands does not work

От
"Christo Romberg"
Дата:
Hi!

When I try the command createdb mydb from psql, nothing happens.
I get no response whatsoever.
My system is Windows XP Professional Edition, and my
PostgreSQL version is 8.1.3.

I can connect to a database using \c NAME OF DATABASE,
but when trying SQL-commands, nothing happens.

When using pgAdmin III though, everything works fine..

Appreciate all the help I get!

Regards,
Christo

Re: SQL-commands does not work

От
Sean Davis
Дата:


On 6/19/06 2:09 PM, "Christo Romberg" <coromberg@gmail.com> wrote:

> Hi!
>
> When I try the command createdb mydb from psql, nothing happens.

First, createdb is a command-line program and not a psql (or SQL) command.
The equivalent SQL command, which can be run from within psql is:

CREATE DATABASE mydb;

> I get no response whatsoever.
> My system is Windows XP Professional Edition, and my
> PostgreSQL version is 8.1.3.
>
> I can connect to a database using \c NAME OF DATABASE,
> but when trying SQL-commands, nothing happens.

You need to finish SQL statements with a semicolon.  My guess is that is
your problem.

Sean


Re: SQL-commands does not work

От
Oisin Glynn
Дата:
Christo Romberg wrote:
> Hi!
>
> When I try the command createdb mydb from psql, nothing happens.
> I get no response whatsoever.
> My system is Windows XP Professional Edition, and my
> PostgreSQL version is 8.1.3.
>
> I can connect to a database using \c NAME OF DATABASE,
> but when trying SQL-commands, nothing happens.
>
> When using pgAdmin III though, everything works fine..
>
> Appreciate all the help I get!
>
> Regards,
> Christo
Are you terminating the commands with";" or the relevant termination
character;
try doing
select now();

Oisin


Re: SQL-commands does not work

От
"Michael Swierczek"
Дата:
> When I try the command createdb mydb from psql, nothing happens.
> I get no response whatsoever.
> My system is Windows XP Professional Edition, and my
> PostgreSQL version is 8.1.3.
>
> I can connect to a database using \c NAME OF DATABASE,
> but when trying SQL-commands, nothing happens.

Forgive me for asking the obvious question, but are you ending your
commands with a semicolon?  Psql doesn't try to do anything until it
gets the semicolon.

pgAdmin III will execute SQL without the semicolon present, although
it will not let you do multiple SQL commands at the same time without
seperating them by semicolons.

-Mike

>
> When using pgAdmin III though, everything works fine..
>
> Appreciate all the help I get!
>
> Regards,
> Christo
>

Re: SQL-commands does not work

От
"Christo Romberg"
Дата:
Hi guys!

When running createdb mydb; I get the following error message:

ERROR:  syntax error at or near "createdb" at character 1
LINE 1: createdb mydb;
        ^

Why can't I use createdb instead of create database?
Same error occur when trying many other commands.

Thanks in advance guys!

Regards,
Christo

Re: SQL-commands does not work

От
Richard Broersma Jr
Дата:
> When running *createdb mydb; *I get the following error message:
>
> ERROR:  syntax error at or near "createdb" at character 1
> LINE 1: createdb mydb;
>         ^
>
> Why can't I use createdb instead of create database?
> Same error occur when trying many other commands.

createdb is a linux/DOS shell command not a PostgreSQL SQL command.

You would find createdb in your ".../bin/" directory.

Notice:
http://www.die.net/doc/linux/man/man1/createdb.1.html

Hope this explains it a little bit better.

Regards,

Richard Broersma Jr.