Re: How to "use" database?

Поиск
Список
Период
Сортировка
От Shane Ambler
Тема Re: How to "use" database?
Дата
Msg-id 47E9BC4D.2070202@Sheeky.Biz
обсуждение исходный текст
Ответ на How to "use" database?  (Anton Andreev <anton.andreev@fmi.uni-sofia.bg>)
Ответы Re: How to "use" database?  (Anton Andreev <anton.andreev@fmi.uni-sofia.bg>)
Список pgsql-general
Anton Andreev wrote:
> Hi,
>
> How to use a database I have just created  in a script that  I am
> executing in Pgadmin3 on Windows?

If you are in pgAdmin then you don't need the connect command. When you
select the db from the side list it connects you and lists the contents
of the db.
 From the query window in pgAdmin (where you can enter any sql
statements) which is where I think you are opening your script file, it
will have a popup menu that you can choose the db to run the commands on
(or the sql script you are opening).

> I can not use "USE Northwind;" or "\connect Northwind;"?

I believe you get the USE command from MS SQL Server examples - postgres
doesn't have that command.

The \connect is a 'shell' command used in psql - the cli based postgres
client that comes with postgresql. This would not be recognised in the
pgAdmin query window, which would only accept valid SQL statements.


I am thinking that if you are writing a script that creates a db then
wants to connect to it and create tables etc, you should look at sending
it to psql.

 From a dos prompt you can use something like -
psql -U postgres -W -f myscript.sql


If you start psql then you can use the psql command \i myscript.sql to
run the script.

You may need to add full pathnames in these examples.



--

Shane Ambler
pgSQL (at) Sheeky (dot) Biz

Get Sheeky @ http://Sheeky.Biz

В списке pgsql-general по дате отправления:

Предыдущее
От: Justin
Дата:
Сообщение: Re: Make MS Access "UPDATE" PostGre SQL Table
Следующее
От: "Jonathan Bond-Caron"
Дата:
Сообщение: Re: PostgreSQL Replication with read-only access to standby DB