Executing SQL commands in script files
Executing SQL commands in script files
От:
"Susan Hoddinott" <susan@perth.dialix.com.au>
Дата:
Following reading through all the documentation it is not clear to me how to run a script file containing a number of SQL commands. Presumably I do this through the psql interface but how do I tell it to run a script?
Re: Executing SQL commands in script files
От:
"Andres Ledesma" <aledes@telefonica.net>
Дата:
psql < scriptfile.txt
or in a psql console
\i scriptfile.txt
----- Original Message -----From: Susan HoddinottSent: Thursday, February 13, 2003 5:15 AMSubject: [NOVICE] Executing SQL commands in script filesFollowing reading through all the documentation it is not clear to me how to run a script file containing a number of SQL commands. Presumably I do this through the psql interface but how do I tell it to run a script?
Re: Executing SQL commands in script files
От:
simran <simran.list@leonardchristian.com>
Дата:
You could pipe in the sql commands... eg. % echo "select * from users" | psql userdb On Thu, 2003-02-13 at 15:15, Susan Hoddinott wrote: > Following reading through all the documentation it is not clear to me > how to run a script file containing a number of SQL commands. > Presumably I do this through the psql interface but how do I tell it > to run a script?
Re: Executing SQL commands in script files
От:
Josh Berkus <josh@agliodbs.com>
Дата:
Susan, > Following reading through all the documentation it is not clear to me how > to run a script file containing a number of SQL commands. Presumably I do > this through the psql interface but how do I tell it to run a script? In PSQL: \i filename From the command line, or from cron: Postgres_dir/bin/psql -U username database < scriptfile Easy as cake! -- Josh Berkus Aglio Database Solutions San Francisco
Re: Generating the db script file ....
От:
"Andres Ledesma" <aledes@telefonica.net>
Дата:
Anybody can tell me how to generate a script from a postgreSQL db ? Thanks in advance, Andrew.
Re: Executing SQL commands in script files
От:
Josh Berkus <josh@agliodbs.com>
Дата:
Susan, > Thank you all for your assistance. My script ran (almost) straight away > having followed your advise. Is the psql interface documented anywhere? I > am used to Oracle and my approach seems a bit "hit-and-miss". Sometimes > Oracle commands work and sometimes they don't! You could try buying a book on PostgreSQL, hmmm? http://techdocs.postgresql.org/techdocs/bookreviews.php http://www.us.postgresql.org/books/index.html -- Josh Berkus Aglio Database Solutions San Francisco
Re: Generating the db script file ....
От:
brew@theMode.com
Дата:
Andrew...... > Anybody can tell me how to generate a script from a postgreSQL db ? A script to do what? The only script that I can think of to get from a postgreSQL database is the backup datafile made via pg_dump, that's a script to restore the database. We need more information. brew