【问题标题】:Row 1 was truncated; it contained more data than there were input columns第 1 行被截断;它包含的数据多于输入列
【发布时间】:2020-08-24 18:50:20
【问题描述】:

这是我的桌子:

CREATE TABLE jobroles ( 
    jobrole_id VARCHAR(80) NOT NULL PRIMARY KEY, 
    jobrole VARCHAR(1000) NOT NULL, 
    jobrole_description VARCHAR(10000) NOT NULL
);

我正在使用这个命令加载我的数据:

LOAD DATA LOCAL INFILE '/Users/harrylevick/Documents/GitHub/jobtech-occupation-selector/data/jobroles.csv' INTO TABLE jobroles FIELDS OPTIONALLY ENCLOSED BY '"' TERMINATED BY ',' ESCAPED BY '\\' LINES TERMINATED BY '\n' IGNORE 1 ROWS;

这是第 1 行:

jobrole_id,jobrole,jobrole_description
c785f4fefed56cc5bcd09ba5728e38323438814508d4c888d6a27e4647b7bc15,1st Assistant Cameraman/Focus Puller* (Specialty Camera Operation),"The 1st Assistant Cameraman/Focus Puller supports the shooting operations for various types of camera equipment including specialty cameras. He/She is responsible for maintaining focus between the lens and subjects. He does this by setting up a complex set of indicators placed on the set floor or props during rehearsal. He collaborates with various production teams to ensure a consistent focus during the shoot. In addition to focus pulling for the camera operator he manages and maintains the camera equipment such as lenses filters and camera boxes for assembling the camera and its accessories for different shots. Before shooting he arrives on the set early to ensure that the camera and all the required lenses are prepared for a day's shoot. At the end of each day he resolves the problems with the 'rushes' and liaises with the film lab to rectify any faults with the camera or film stock. He then proceeds to clean the equipment and pack it up in preparation for the next day's shoot. He may also be required to set up and mount specialty camera equipment and assist in the operation of specialty cameras such as 360 cameras underwater cameras and aerial cameras during the shoot.The work involves physically demanding tasks especially the capture of motion sequences amidst high pressure. He is expected to operate in an outdoors environment and may be required to travel depending on the location of the shoot. He needs to have strong knowledge of camera equipment a strong affinity with technology knowledge of the relevant electronics and an in-depth knowledge of the principles of camera work. He is required to be an effective team player and shows diplomacy and sensitivity when working with artists production staff and crew. He should have good colour vision and excellent hand-eye co-ordination."

我真的不知道为什么它会被截断,因为我使用了 OPTIONALLY ENCLOSED BY '"' 命令来捕获文本中的任何额外逗号。

【问题讨论】:

  • 但您还指定了 ENCLOSED BY '"'
  • 哪一列的值真的被截断了?它的最终价值是多少?

标签: mysql sql truncate


【解决方案1】:

ENCLOSED BY '"' 表示您应该将列包含在“

取自mysql文档https://dev.mysql.com/doc/refman/8.0/en/load-data.html

如果输入值不一定包含在引号内 标记,请在 ENCLOSED BY 选项之前使用 OPTIONALLY。

【讨论】:

  • 我已经用更新的命令编辑了我的帖子,但仍然会截断第一行
  • 如果你在 Windows 上工作,你也可以把 LINES TERMINATED BY '\r\n'
  • 还将 FIELDS .. TERMINATED BY 子句放在 ENCLOSED BY 子句之前
猜你喜欢
  • 2015-02-19
  • 1970-01-01
  • 1970-01-01
  • 2014-01-09
  • 2021-03-14
  • 1970-01-01
  • 2013-12-24
  • 2019-11-18
  • 2021-08-19
相关资源
最近更新 更多