Forum OpenACS Q&A: How execute one script in postgres

Collapse
Posted by Dayra Munoz on
Hi friends:

I want one test that is execute a script from postgresql, that
contains this:

name script: create_table.sql
Content: create table test (id primary key, name varchar(100)

How call or execute this script (ubicate
in /var/lib/aolserver/servers/openacs4/www/create_table.sql) from the
promt of postgreSQL, psql-openacs4# ?

Help please.  It question sound strainged but i dont know... :(
Thanks

Collapse
Posted by Patrick Giagnocavo on
If you are running the psql command line shell, you can use i to run the file.  On my systems, psql is compiled with readline support, so you can put in a part of the path and hit the TAB key to expand the path, similar to what you can do in the bash shell or with later versions of ksh.

As well, you can load the file by exiting psql and running psql -f /var/lib/aolserver/servers/openacs4/www/create_table.sql .

If however, you want to run only some of the SQL commands in the file but not others, I don't know how to do that from within psql itself.

Collapse
Posted by Jonathan Marsden on
Try
i /var/lib/aolserver/servers/openacs4/www/create_table.sql

at the psql prompt.