Re: newbie question: reading sql commands from script

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: Sean Davis <sdavis2(at)mail(dot)nih(dot)gov>
Cc: basel novo <baselnovo(at)hotmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: newbie question: reading sql commands from script
Date: 2005-10-25 09:23:22
Message-ID: 1130232202.30145.112.camel@linda.lfix.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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(at)postgresql(dot)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(at)lfix(dot)co(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2005-10-25 09:25:38 Re: Deleting vs foreign keys
Previous Message Martijn van Oosterhout 2005-10-25 09:21:06 Re: pg_dump, MVCC and consistency