Thread: batch file

batch file

From
Milen
Date:
Hi all!,

I want to execute several SQL statements one after another.
Does anyone know if it is possible to create something like a "batch file" 
which contains all SQL commands I want.

Best Regards:
Milen


Re: batch file

From
Jason Earl
Date:
I just put files commands that I want in some file
like "foo.sql" and then do:

psql mydatabase -f foo.sql

Is this what you are looking for?

Jason


--- Milen <milend@ansco.com> wrote:
> Hi all!,
> 
> I want to execute several SQL statements one after
> another.
> Does anyone know if it is possible to create
> something like a "batch file" 
> which contains all SQL commands I want.
> 
> Best Regards:
> Milen
> 
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
> http://www.postgresql.org/users-lounge/docs/faq.html


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/


Re: batch file

From
Jie Liang
Date:
Hi,

I am not sure what's your question.
However, you can list a bunch of SQL statements in a text file:
e.g.
myfile.sql which contains:

select * from tablename where ....
update tablename set ... where ...
.....

then, you can just run it like:


psql -q dbname < myfile.sql




Jie LIANG

St. Bernard Software

10350 Science Center Drive
Suite 100, San Diego, CA 92121
Office:(858)320-4873

jliang@ipinc.com
www.stbernard.com
www.ipinc.com

On Fri, 25 May 2001, Milen wrote:

> Hi all!,
> 
> I want to execute several SQL statements one after another.
> Does anyone know if it is possible to create something like a "batch file" 
> which contains all SQL commands I want.
> 
> Best Regards:
> Milen
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
> http://www.postgresql.org/users-lounge/docs/faq.html
> 



Re: batch file

From
Peter Eisentraut
Date:
Milen writes:

> I want to execute several SQL statements one after another.
> Does anyone know if it is possible to create something like a "batch file"
> which contains all SQL commands I want.

psql [options] -f yourfile.sql

-- 
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter



Re: batch file

From
"Richard Huxton"
Date:
From: "Milen" <milend@ansco.com>
> I want to execute several SQL statements one after another.
> Does anyone know if it is possible to create something like a "batch file"
> which contains all SQL commands I want.

You can do exactly that.

Use "man psql" to find out about the -f option or the \i option.

- Richard Huxton



Re: batch file

From
"bugi"
Date:
Create the file for example command.sql and log into the  database psql
mydbase
and write command
\i command.sql

U�ytkownik "Milen" <milend@ansco.com> napisa� w wiadomo�ci
news:01C0E51F.F2E673F0.milend@ansco.com...
> Hi all!,
>
> I want to execute several SQL statements one after another.
> Does anyone know if it is possible to create something like a "batch file"
> which contains all SQL commands I want.
>
> Best Regards:
> Milen
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html




Re: batch file

From
Grant
Date:
> I want to execute several SQL statements one after another.
> Does anyone know if it is possible to create something like a "batch file"
> which contains all SQL commands I want.

That or just separate commands by a semi colon:

select * from table1; select * from table2;