Re: Loading database from script files
Posted in 1994
John Sinues (sinues@prcd.prc.mrms.navy.mil) wrote:
> I have an ASCII file containing a number of INSERT-INTO statements. I
> want to execute this file and load an Informix OnLine database. Two questions:
> 1. How can I load this script from the command line? Can I
> do something like this:
> isql -ansi {dbname} < {SQL_script.sql file}
> 2. How should my SQL_script.sql file end? I have a "COMMIT WORK"
> statement at the end -- do I need anything else? I know in
> Oracle, my SQL script must have a "COMMIT;" then on the next
> line an "EXIT;" which terminates the SQL session. Do I need
> anything like that for Informix?
> The script looks somethings like this:
> INSERT INTO table1 ( column1, column2 )
> VALUES ( 8, 9 );
> INSERT INTO table1 ( column1, column2 )
> VALUES ( 1, 2 );
> INSERT INTO table1 ( column1, column2 )
> VALUES ( 5, 7 );
> COMMIT WORK;
> EXIT; <- is this needed? how to I leave isql?
> Thanks in advance. (^8
> --
> ============================================================================
> _/_/_/_/ _/_/_/_/ _/_/_/_/ John C. Sinues
> _/ _/ _/ _/ _/
> _/ _/ _/ _/ _/ Inc.
> _/_/_/_/ _/_/_/_/ _/ eMail: sinues@prcd.prc.mrms.navy.mil
> _/ _/ _/ _/ Phone: (804) 498-5666
> _/ _/ _/ _/_/_/_/ Fax: (804) 498-5670
> =======================================
> | "...life is robust and meant to be
> | lived, joyfully...but not perfectly-
> | except by accident."
> ============================================================================
Try:
isql dbname scriptfilename.sql
The Informix isql commands in the script file will be executed in order.
When it reaches EOF the isql command will terminate normally.
Danni