Hi, Why don't you run the CREATE TABLE query with the IF NOT EXISTS clause then your script could look like this
CREATE TABLE IF NOT EXISTS table_name ...; ALTER TABLE table_name; If the table already exists only the ALTER statement will be executed, otherwise the ALTER statement will not do anything. Check the MySQL Reference for more details http://dev.mysql.com/doc/refman/4.1/en/create-table.html HTH -- Dobromir Velev [EMAIL PROTECTED] http://www.websitepulse.com/ On Friday 11 November 2005 14:14, Luke wrote: > Hey all, > > I've got a question for you. What would be the best way to set up a set of > srcipts to create\Update the databse when my app is installed? > > The problem is that I obviously can't just drop the database cause if the > database is already installed then the client would lose all his data. I > need a way to update the collumns in each table if they change but still > keep the clients data. Stored Procedures, Views and Triggers are easy cause > these I can drop then create again but tables are a bit more complex. > > I thought of writing something to the effect of : > > USE Information_Schema; > > IF (SELECT Table_Name FROM Tables WHERE TableName = '<TableName>' AND > Table_Schema = '<Database>') IS NULL THEN BEGIN > {Create Table} > END; > ELSE > BEGIN > {Alter Table} > END; > END IF; > > Is there not a better way of doing things? We want to try and create\update > the database through scripts which can then be deleted instead of writing > an app. > > Any help would be greatly appreciated > > Thanx, > Luke -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]