Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MYSQL: Create Table If Not Exists

Tags:

sql

mysql

If I do a Create Table If Not Exists, and a table with the same name exists with fewer rows (or columns), what would happen?

like image 938
Marin Avatar asked Dec 14 '22 06:12

Marin


2 Answers

The table will not be created if a table with the same name already exists regardless of table layout.

like image 170
Robert Gamble Avatar answered Dec 17 '22 23:12

Robert Gamble


Nothing. If the "IF Not Exists" clause fails, the rest of the create is skipped.

like image 41
Bill the Lizard Avatar answered Dec 17 '22 22:12

Bill the Lizard