[plug] update a mysql script

J Michael Gilks mike.gilks at westnet.com.au
Sat Dec 31 16:38:03 WST 2005


On Saturday 31 December 2005 15:37, Jon Miller wrote:
> I have a file that creates a mysql database when I do the following:
> mysql <create.sql
> The database already exists, but I was told I need to re enter the command
> and now I'm getting the database already exist.  Is there a way to running
> this command with some form or overwrite command or update command.
>
In the script 'create.sql' you probably have a line which says
create database somedb
or similar.
This needs to be changed to 
create database if not exists somedb
then if the database is already there it will be ignored.

If you are creating tables in the same script you will have to do the same for 
all the tables also.

See the documentation at
http://dev.mysql.com/doc/refman/4.1/en/create-database.html

Hope this helps.

Love
Mike.



More information about the plug mailing list