问题描述
创建表时报如下warning
mysql> CREATE TABLE IF NOT EXISTS score(
-> stu_id VARCHAR(10),
-> course_id VARCHAR(10),
-> score INT
-> );
Query OK, 0 rows affected, 1 warning (0.01 sec)
解决方法
show warnings;
查看详细警告信息,显示表已存在;
show table like ‘score’
发现确实已创建;
查看score表,因其已存在,新表未创建成功。
修改表名,重新创建表
mysql> show warnings;
+-------+------+------------------------------+
| Level | Code | Message |
+-------+------+------------------------------+
| Note | 1050 | Table 'score' already exists |
+-------+------+------------------------------+
1 row in set (0.00 sec)
mysql> show tables like 'score';
+------------------------+
| Tables_in_qn01 (score) |
+------------------------+
| score |
+------------------------+
1 row in set (0.01 sec)
mysql> select * from score;
+------+------+-----------+--------+
| id | sex | chinese_s | math_s |
+------+------+-----------+--------+
| 0 | 0 | 70 | 50 |
| 1 | 0 | 90 | 70 |
| 2 | 1 | 80 | 90 |
+------+------+-----------+--------+
3 rows in set (0.01 sec)