batch file

Started by Hugo Coolensabout 24 years ago4 messagesgeneral
Jump to latest
#1Hugo Coolens
hugo.coolens@skynet.be

In the postgresql tutorial it is explained how to enter commands one by
one, I was wondering whether it is possible to first put a series of
commands in an ascii file and then read in that file with psql. Here are
my questions:
1. What should be the default extension of such a file
2. Which command in psql should I use to read in suc a file

best regards,
hugo

#2Lee Harr
missive@frontiernet.net
In reply to: Hugo Coolens (#1)
Re: batch file

In the postgresql tutorial it is explained how to enter commands one by
one, I was wondering whether it is possible to first put a series of
commands in an ascii file and then read in that file with psql. Here are
my questions:
1. What should be the default extension of such a file

I do not know of a standard. How about .sql ?

2. Which command in psql should I use to read in suc a file

\i commands.sql

Also, take a look at \? which will show you other goodies.

#3Rich Shepard
rshepard@appl-ecosys.com
In reply to: Lee Harr (#2)
Re: batch file

On Thu, 21 Feb 2002, Lee Harr wrote:

2. Which command in psql should I use to read in suc a file

\i commands.sql

Or, use 'psql -f <filename>'. You can also use the '-d' switch to specify
the database to use. I just learned all this earlier this week and it works
like a charm.

Rich

Dr. Richard B. Shepard, President

Applied Ecosystem Services, Inc. (TM)
2404 SW 22nd Street | Troutdale, OR 97060-1247 | U.S.A.
+ 1 503-667-4517 (voice) | + 1 503-667-8863 (fax) | rshepard@appl-ecosys.com
http://www.appl-ecosys.com

#4Bruce Momjian
bruce@momjian.us
In reply to: Hugo Coolens (#1)
Re: batch file

Hugo Coolens wrote:

In the postgresql tutorial it is explained how to enter commands one by
one, I was wondering whether it is possible to first put a series of
commands in an ascii file and then read in that file with psql. Here are
my questions:
1. What should be the default extension of such a file

Any.

2. Which command in psql should I use to read in suc a file

psql -f filename.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026