List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:June 9 1999 2:31am
Subject:Re: Table exists ?
View as plain text  
At 12:02 PM +1000 6/9/1999, 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
>aborted
>
>e.g.
>
>./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.


You'll probably have to write a script.  Your problem involves executing
a query contingent on the results of earlier queries, which is difficult to
achieve with straight SQL.

--
Paul DuBois, paul@stripped
Northern League Chronicles: http://www.snake.net/nl/
Thread
Table exists ?Derek Lavine8 Jun
  • Re: Table exists ?Christian Mack8 Jun
  • Re: Table exists ?Jim Faucette8 Jun
  • RE: Table exists ?Jeff Magnusson8 Jun
  • Re: Table exists ?Derek Lavine9 Jun
    • Re: Table exists ?Paul DuBois9 Jun
    • Re: Table exists ?Michael Widenius9 Jun
  • Re: Table exists ?Sasha Pachev9 Jun
  • Re: Table exists ?Ronald Beck9 Jun
RE: Table exists ?tcobb9 Jun