I am using MySQL 5.0+ and I am trying to execute a big list of commands if a table does not exist. So I would like to have:
if not exist table
then
10000 line query that creates and populates the table with a lot of entries.
end if
The only problem is that I have been searching and so far I found out that MySQL does not support such a feature.
At the current moment I have:
IF NOT EXISTS `profiles`
THEN
A LOT OF QUERIES;
END IF;
For some reason it keeps on giving me error saying syntax is wrong on line 1.
So I was wondering if anyone would happen to have a better idea as to how go about approaching this problem, or how to fix it.
Addding on to code from bfavaretto, if you do have information_schema.tables, try something like this: