Derek Lavine wrote:
> Thanks for the suggestions so far but I think I was not clear enough, sorry.
> What I have is an SQL script that creates a number of tables. Before each
> create I want to check if the table already exists and if it does I will not
> create it. I need to do this as otherwise as soon as an error is encountered
> (which it is if one tries to create a tablethat already exists) the script is
> ./mysql -u user -p password mydb < mysqlscript.sql
> if mysqlscript.sql contains a create for a table that is already present the
> script will be aborted. I don't know how (in the script) to check if the
> table is present.
> Is there a way of doing this or will I have to write a perl script that will
> call individual create table scripts if the table does not exist.
> Thanks again
Here is a dirty trick I use in situations that are probably similar to
mysql -f -uuser -psecret < file.sql
That will force the script to continue even if an error occurs, quick
and dirty, but does the job.