LOAD DATA LOCAL INFILE - 只插入一行

时间:2014-09-14 10:39:56

标签: mysql sql

我最近从SQL中越过了一段时间并且仍然遇到了一些麻烦。任何人都可以帮助我这个拦截器。我确信这是我犯的一些愚蠢的错误,但我无法通过它。

然后我创建了表:

create table FFX_DCM_RawData (
    ID int,
    Campaign varchar (256),
    Site_DFA varchar (256),
    Placement varchar (256),
    Report_Date varchar (256),
    Creative varchar (256),
    Ad varchar (256),
    Impression integer,
    Clicks integer,
    Media_Cost decimal (5,2),
    MobileClickToCall_Buy_PostClick integer,
    MobileClickToCall_Buy_PostView integer,
    MobileClickToCall_Rent_PostClick integer,
    MobileClickToCall_Rent_PostView integer,
    MobileEmailEnquiry_Buy_PostClick integer,
    MobileEmailEnquiry_Buy_PostView integer,
    MobileEmailEnquiry_Rent_PostClick integer,
    MobileEmailEnquiry_Rent_PostView integer,
    DesktopClickToReveal_Buy_PostClick integer,
    DesktopClickToReveal_Buy_PostView integer,
    DesktopClickToReveal_Rent_PostClick integer,
    DesktopClickToReveal_Rent_PostView integer,
    DesktopEmailEnquiry_Buy_PostClick integer,
    DesktopEmailEnquiry_Buy_PostView integer,
    DesktopEmailEnquiry_Rent_PostClick integer,
    DesktopEmailEnquiry_Rent_PostView integer
);

并通过INFILE ...

插入
LOAD DATA LOCAL INFILE 'Users//Jakub//Desktop//DCM Data_All Channels.csv' INTO TABLE test.FFX_DCM_RawData
    FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' (Id, Campaign, Site_DFA, Placement, Report_Date,
Creative, Ad, Impression, Clicks, Media_Cost, MobileClickToCall_Buy_PostClick, MobileClickToCall_Buy_PostView,
MobileClickToCall_Rent_PostClick, MobileClickToCall_Rent_PostView, MobileEmailEnquiry_Buy_PostClick,
MobileEmailEnquiry_Buy_PostView, MobileEmailEnquiry_Rent_PostClick, MobileEmailEnquiry_Rent_PostView,
DesktopClickToReveal_Buy_PostClick, DesktopClickToReveal_Buy_PostView, DesktopClickToReveal_Rent_PostClick,
DesktopClickToReveal_Rent_PostView, DesktopEmailEnquiry_Buy_PostClick, DesktopEmailEnquiry_Rent_PostClick,
DesktopEmailEnquiry_Rent_PostView
);

但结果总是只插入一行。谁知道我哪里出错?

1 个答案:

答案 0 :(得分:0)

我不确定,但这是heidisql的默认值,而csv upload

FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\r\n' ESCAPED BY '"'

此外,如果您使用excel,也可以参考此answer