Mysql Alter table if column not Exists
Example:
Example:
IF NOT EXISTS( SELECT NULL
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'tablename'
AND table_schema = 'db_name'
AND column_name = 'columnname') THEN
ALTER TABLE `TableName` ADD `ColumnName` Varchar(100) NOT NULL default '';
END IF;
0 Comments