I am creating table in MySql by using the coomand, create table person ( id int, name int)
. Actually, I want to create table person if there exists no person table in database. Can anybody help me, how to acive this ?
Asked
Active
Viewed 156 times
0

alessandro
- 1,681
- 10
- 33
- 54
-
This might help: http://stackoverflow.com/questions/84330/mysql-create-table-if-not-exists-else-truncate – Dan Feb 02 '12 at 22:23
-
Or this: http://stackoverflow.com/questions/9069179/if-table-does-not-exist-execute-a-long-query/9069391#9069391 – thursdaysgeek Feb 02 '12 at 22:40
4 Answers
2
The manual page says that you should use
CREATE TABLE IF NOT EXISTS person (id int, name int);

Joachim Isaksson
- 176,943
- 25
- 281
- 294