Skip site navigation (1) Skip section navigation (2)

Re: Path for pgsql \i option?

From: Jason Tan <jason(at)rebel(dot)rebel(dot)net(dot)au>
To: Francisco Reyes <lists(at)natserv(dot)com>
Cc: Pgsql Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Path for pgsql \i option?
Date: 2001-09-11 05:30:06
Message-ID: Pine.LNX.3.95.1010911145359.27217I-100000@rebel.rebel.net.au (view raw or flat)
Thread:
Lists: pgsql-novice
You can specify absolute paths.

contacts=# \! pwd
/home/jtan
contacts=# \! ls /home/jtan/Projects/contacts/db
:	    basedata		 builddb.sql   granter.pl  plpgsql.sql
;w	    basedata.sql	 entitydb.sql  log	   tables
RCS	    belongs_to_org.sql	 flech	       logger.sql  testdata.sql
Table1.txt  belongs_to_org2.sql  grant_apache  pids	   testfunc
contacts=# \i /home/jtan/Projects/contacts/db/testdata.sql

The above will work.

You can also speicify relative paths:

contacts=# \!pwd       
contacts=# \! ls ..
:	    basedata		 builddb.sql   granter.pl  plpgsql.sql
;w	    basedata.sql	 entitydb.sql  log	   tables
RCS	    belongs_to_org.sql	 flech	       logger.sql  testdata.sql
Table1.txt  belongs_to_org2.sql  grant_apache  pids	   testfunc
contacts=#       
/home/jtan/Projects/contacts/db/flech
contacts=# \i ../testdata.sql

You can also include lots of \i directives in a file you run with \i.
Eg if have a file called builddb.sq; that contains:

\i schema.sql
\i /home/cotnacts/data/base/data.sql
\i ../testdata.sql

You can then go:

\i builddb.sql

and it will try to run a file in the crrent dir called schema.sql it will run 
that and it will run /home/contacts/data/base/data.sql it will then run
../testdata.sql.

You can find this stuff our really easily by trying it.

Jason

On Tue, 11 Sep 2001, Francisco Reyes wrote:

> I have a number of files I need to include during my database design and
> testing.
> 
> Is there a way to specify some form of path for pgsql so when I use "\i"
> it would know what directory to try and load the file from?
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
> 

--
------------------------------------------------------------------------------
Jason Tan                                                jason(at)rebel(dot)net(dot)au
     "Democracy is two wolves and a lamb voting on what to have for lunch. 
                 Liberty is a well-armed lamb contesting the vote."
                               ~Benjamin Franklin, 1759
------------------------------------------------------------------------------


In response to

Responses

pgsql-novice by date

Next:From: Bo LorentsenDate: 2001-09-11 07:43:49
Subject: accumulate setof ?
Previous:From: Jason TanDate: 2001-09-11 05:22:52
Subject: Re: Insert using a subselect?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group