gpt4 book ai didi

mysql - SQL插入语句出错

转载 作者:行者123 更新时间:2023-11-29 03:00:49 25 4
gpt4 key购买 nike

我将一个记录集从一个数据库导出到一个 csv 文件,当我尝试使用 mysql workbench 将它导入另一个数据库时,我保留了这条错误消息:

Executing SQL script in server

ERROR: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 'Lord it Over', 'Ben', '1993-03-01', 'TRC', NULL, 1983, '1999-09-01', 'NULL', '' at line 1



INSERT INTO `TRC`.`horse`
(`horse_id`, `registered_name`, `stable_name`, `arrival_date`, `last_known_location`, `is_ex_racer`, `birth_year`, `death_date`, `horse_comments`, `sex`, `referral_date`, `horse_height`, `arrival_weight`, `passport_no`, `microchip_no`, `is_on_waiting_list`) VALUES
(, 'Lord it Over', 'Ben', '1993-03-01', 'TRC', NULL, 1983, '1999-09-01', 'NULL', 'NULL', 'NULL', NULL, NULL, 'NULL', 'NULL', 0)



SQL script execution finished: statements: 29 succeeded, 1 failed



Fetching back view definitions in final form.

Nothing to fetch

任何帮助将不胜感激,因为据我所知,他们似乎没有错误。

最佳答案

因为

  • VALUES 以逗号开头。
  • 您错过了 horse_id。如果是标识列,则删除 horse_Id

像这样尝试(如果 horse_Id 是身份)

INSERT INTO `TRC`.`horse` 
(`registered_name`, `stable_name`, `arrival_date`, `last_known_location`, `is_ex_racer`, `birth_year`, `death_date`, `horse_comments`, `sex`, `referral_date`, `horse_height`, `arrival_weight`, `passport_no`, `microchip_no`, `is_on_waiting_list`) VALUES
('Lord it Over', 'Ben', '1993-03-01', 'TRC', NULL, 1983, '1999-09-01', 'NULL', 'NULL', 'NULL', NULL, NULL, 'NULL', 'NULL', 0)

或者(如果 Horse_id 是简单的 int 那么试试这个)

 INSERT INTO `TRC`.`horse` 
(`horse_id`, `registered_name`, `stable_name`, `arrival_date`, `last_known_location`, `is_ex_racer`, `birth_year`, `death_date`, `horse_comments`, `sex`, `referral_date`, `horse_height`, `arrival_weight`, `passport_no`, `microchip_no`, `is_on_waiting_list`) VALUES
('1','Lord it Over', 'Ben', '1993-03-01', 'TRC', NULL, 1983, '1999-09-01', 'NULL', 'NULL', 'NULL', NULL, NULL, 'NULL', 'NULL', 0)
^^^^ -- Here Horse_Id missing

关于mysql - SQL插入语句出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24006528/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com