Thread: newbie question: reading sql commands from script files

newbie question: reading sql commands from script files

From
"basel novo"
Date:
What is the equivalent of the mysql 'source' command for reading sql
commands from ascii script files?

Thanks.

_________________________________________________________________
Don�t just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/


Re: newbie question: reading sql commands from script files

From
"Sean Davis"
Date:
In psql, look at \i.
 
Sean
 
----- Original Message -----
Sent: Monday, October 24, 2005 8:28 PM
Subject: [GENERAL] newbie question: reading sql commands from script files

What is the equivalent of the mysql 'source' command for reading sql
commands from ascii script files?

Thanks.

_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Re: newbie question: reading sql commands from script

From
Oliver Elphick
Date:
On Mon, 2005-10-24 at 20:39 -0400, Sean Davis wrote:
> In psql, look at \i.
>
> Sean
>
>         ----- Original Message -----
>         From: basel novo
>         To: pgsql-general@postgresql.org
>         Sent: Monday, October 24, 2005 8:28 PM
>         Subject: [GENERAL] newbie question: reading sql commands from
>         script files
>
>
>         What is the equivalent of the mysql 'source' command for
>         reading sql
>         commands from ascii script files?

Also, for shell scripting, there are command line options:

   psql -f filename

or redirection:

   psql < filename

(the former gives line numbers), or for a single command:

   psql -c "sql command"

--
Oliver Elphick                                          olly@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA  92C8 39E7 280E 3631 3F0E  1EC0 5664 7A2F A543 10EA
                 ========================================
   Do you want to know God?   http://www.lfix.co.uk/knowing_god.html


Re: newbie question: reading sql commands from script

From
Brent Wood
Date:

On Tue, 25 Oct 2005, basel novo wrote:

> What is the equivalent of the mysql 'source' command for reading sql
> commands from ascii script files?
>

I have not used mysql, so am not familiar with the source command, but to
have postgres run a set of sql statements/queries from a file you can:

psql <DB> -f "filename"



also, to run a single command from a script (or commandline)

psql <DB> -c "<sql command>"



Cheers,

  Brent Wood

Re: newbie question: reading sql commands from script

From
"basel novo"
Date:
Thanks to all who answered this question!

>From: Brent Wood <b.wood@niwa.co.nz>
>To: basel novo <baselnovo@hotmail.com>
>CC: pgsql-general@postgresql.org
>Subject: Re: [GENERAL] newbie question: reading sql commands from script
>Date: Wed, 26 Oct 2005 10:36:34 +1300 (NZDT)
>
>
>
>On Tue, 25 Oct 2005, basel novo wrote:
>
> > What is the equivalent of the mysql 'source' command for reading sql
> > commands from ascii script files?
> >
>
>I have not used mysql, so am not familiar with the source command, but to
>have postgres run a set of sql statements/queries from a file you can:
>
>psql <DB> -f "filename"
>
>
>
>also, to run a single command from a script (or commandline)
>
>psql <DB> -c "<sql command>"
>
>
>
>Cheers,
>
>   Brent Wood
>
>---------------------------(end of broadcast)---------------------------
>TIP 5: don't forget to increase your free space map settings

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/