Обсуждение: Starting psql without a database?

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

Starting psql without a database?

От
"Fred Parkinson"
Дата:
Folks
 
As I have been unable to install pgadmin3 on my OpenSUSE Linux 10 box (erroneously described as 11.2 in the request for help post, that was useless), I have decided to use psql since it seems to be my only option.
 
However, I have no database as yet, and when I type in a console 'psql' I get the message "psql: FATAL: database 'username' does not exist"
So I try to start by sending the createdb command, as in: "psql -c createdb -T DEFAULT 'timecard'" but this returns the error "psql: FATAL:  database "timecard" does not exist"
 
I tried using the database 'postgres' which seems to be created during the install:
psql postgres, which takes me to a psql prompt.  However, the command createdb -T DEFAULT "timecard" now results in the error "syntax error at or neat "createdb" with a carat pointing to the 'c' in 'createdb'.
 
As usual, stuck again!
 
Any ideas greatly appreciated.
Fred

Re: Starting psql without a database?

От
"Kevin Grittner"
Дата:
"Fred Parkinson" <FredP@abag.ca.gov> wrote:

> I tried using the database 'postgres' which seems to be created
> during the install:
> psql postgres, which takes me to a psql prompt.  However, the
> command createdb -T DEFAULT "timecard" now results in the error
> "syntax error at or neat "createdb" with a carat pointing to the
> 'c' in 'createdb'.

I think you're confusing the OS command-line executable createdb:

http://www.postgresql.org/docs/9.0/interactive/app-createdb.html

and the SQL command CREATE DATABASE:

http://www.postgresql.org/docs/9.0/interactive/sql-createdatabase.html

-Kevin

Re: Starting psql without a database?

От
"Fred Parkinson"
Дата:
Right you are!  'CREATE DATABASE' worked (started psql with the postgres database) where createdb didn't.
 
Was there some way to tell from the documentation that createdb is to run from the shell while CREATE DATABASE is run from the psql prompt?   I assumed all database-related commands are run from the psql prompt.
 
Thanks again, Fred
 

>>> "Kevin Grittner" <Kevin.Grittner@wicourts.gov> 04/27/2011 11:51 AM >>>
"Fred Parkinson" <FredP@abag.ca.gov> wrote:

> I tried using the database 'postgres' which seems to be created
> during the install:
> psql postgres, which takes me to a psql prompt.  However, the
> command createdb -T DEFAULT "timecard" now results in the error
> "syntax error at or neat "createdb" with a carat pointing to the
> 'c' in 'createdb'.

I think you're confusing the OS command-line executable createdb:

http://www.postgresql.org/docs/9.0/interactive/app-createdb.html

and the SQL command CREATE DATABASE:

http://www.postgresql.org/docs/9.0/interactive/sql-createdatabase.html

-Kevin

Re: Starting psql without a database?

От
"Kevin Grittner"
Дата:
"Fred Parkinson" <FredP@abag.ca.gov> wrote:

> Was there some way to tell from the documentation that createdb is
> to run from the shell while CREATE DATABASE is run from the psql
> prompt?

One is in the "PostgreSQL Client Applications" section, along with
psql and pg_dump.  The other is in the "SQL Commands" section.
Applications run in the OS shell, while SQL commands run in a
database session.

-Kevin

Re: Starting psql without a database?

От
Tom Lane
Дата:
"Fred Parkinson" <FredP@abag.ca.gov> writes:
> Was there some way to tell from the documentation that createdb is to run from the shell while CREATE DATABASE is run
fromthe psql prompt? 

The reference section of the manual documents the former under "Client
Applications" and the latter under "SQL Commands".

            regards, tom lane