表不存在时创建表
时间:2010-04-12 来源:ubuntuer
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| enum_test |
| index_test |
+----------------+
2 rows in set (0.00 sec)
mysql> create table if not exists a(id INT not null, name VARCHAR(15) not null, age INT UNSIGNED not null);
Query OK, 0 rows affected (0.01 sec)
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| a |
| enum_test |
| index_test |
+----------------+
3 rows in set (0.00 sec)
mysql> create table if not exists a(id INT not null, name VARCHAR(15) not null, age INT UNSIGNED not null);
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| a |
| enum_test |
| index_test |
+----------------+
3 rows in set (0.00 sec)
跑程序的时候特别是c程序的时候 建议创建表 加上if not exist....