增加1条SQL记录报错:
1 Operation failed: There was an error while applying the SQL script to the database.
2 Executing:
3 INSERT INTO `autotestcase`.`testcase` (`id`, `api_purpose`, `request_url`, `request_method`, `request_data_type`, `request_data`, `assert_method`, `check_point`, `correlation`, `active`, `creater`, `project`) VALUES ('4799', '租房列表', '/appapi/rent/1/v1/prolist', 'POST', 'Data', '{\"page\":1,\"pcount\":\"6080583\"}', 'assertIn', '\"status\":\"200\",\"msg\":\"OK\"', '', 'Yes', '王菊', 'gw_lt');
4
5 ERROR 1062: 1062: Duplicate entry '4799' for key 'PRIMARY'
6 SQL Statement:
7 INSERT INTO `autotestcase`.`testcase` (`id`, `api_purpose`, `request_url`, `request_method`, `request_data_type`, `request_data`, `assert_method`, `check_point`, `correlation`, `active`, `creater`, `project`) VALUES ('4799', '租房列表', '/appapi/rent/1/v1/prolist', 'POST', 'Data', '{\"page\":1,\"pcount\":\"6080583\"}', 'assertIn', '\"status\":\"200\",\"msg\":\"OK\"', '', 'Yes', '王菊', 'gw_lt')
问题解析:
Duplicate entry '4799' for key 'PRIMARY'
主键设置了唯一约束,看来是4799这个id已经被使用过了,所以再次插入4799的记录会有冲突
解决办法:
查看最大的id值
把新增记录的id值改为 max(id)+1
修改后再次执行sql语句,成功。