gpt4 book ai didi

mysql - LOAD DATA LOCAL INFILE 语法错误

转载 作者:可可西里 更新时间:2023-11-01 08:45:03 26 4
gpt4 key购买 nike

使用 MySQL:mysql Ver 14.14 Distrib 5.6.24,用于使用 EditLine 包装器的 debian-linux-gnu (x86_64)

我正在尝试每天运行两次 LOAD DATA LOCAL INFILE 作业。我很难整理我的语法。目前,我有这个:

#!/bin/bash

mysql --user=dbuser --password="dbuserpassword" --database=DSDB --local-infile --execute "

LOAD DATA LOCAL INFILE '/mnt/hqsccm/TSReport.CSV'
INTO TABLE temptable
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\r\n'
(@compname,@imgdate,@imgname,@imgsttime,@imgendtime,@tottime,@engname,@engemail) set ComputerName=@compname,ImagingDate=@imgdate,ImageName=@imgname,ImageSTartTime=@imgsttime,ImageEndTime=@imgendtime,TotalTime=@tottime,EngineerName=@engname,EngineerEmail=@engemail;

TRUNCATE HQSCCMmachines;

INSERT INTO HQSCCMmachines (ComputerName,ImagingDate,ImageName,ImageSTartTime,ImageEndTime,TotalTime,EngineerName,EngineerEmail)
SELECT (ComputerName,ImagingDate,ImageName,ImageSTartTime,ImageEndTime,TotalTime,EngineerName,EngineerEmail)
FROM temptable

TRUNCATE temptable;
"

我不断得到这个:

ERROR 1064 (42000) at line 11: 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 'temptable' at line 5

帮忙吗?

最佳答案

这应该可以工作(如果文件和表存在)-

    LOAD DATA LOCAL INFILE '/mnt/hqsccm/TSReport.CSV'
INTO TABLE temptable
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\r\n'
(@compname,@imgdate,@imgname,@imgsttime,@imgendtime,@tottime,@engname,@engemail) set ComputerName=@compname,ImagingDate=@imgdate,ImageName=@imgname,ImageSTartTime=@imgsttime,ImageEndTime=@imgendtime,TotalTime=@tottime,EngineerName=@engname,EngineerEmail=@engemail;

TRUNCATE HQSCCMmachines;

INSERT INTO HQSCCMmachines (ComputerName,ImagingDate,ImageName,ImageSTartTime,ImageEndTime,TotalTime,EngineerName,EngineerEmail)
SELECT ComputerName,ImagingDate,ImageName,ImageSTartTime,ImageEndTime,TotalTime,EngineerName,EngineerEmail
FROM temptable;

TRUNCATE temptable;

关于mysql - LOAD DATA LOCAL INFILE 语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31283842/

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