Re: newbie question: reading sql commands from script

From: Brent Wood <b(dot)wood(at)niwa(dot)co(dot)nz>
To: basel novo <baselnovo(at)hotmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: newbie question: reading sql commands from script
Date: 2005-10-25 21:36:34
Message-ID: 20051026103326.L51409@storm-user.niwa.co.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Fetter 2005-10-25 22:00:27 Re: Getting Stated
Previous Message Robert Treat 2005-10-25 21:33:51 Re: Map of Postgresql Users (OT)