我有以下查询,有效:
mysql -u root --local-infile=1 home -e "
LOAD DATA LOCAL INFILE '$1'
INTO TABLE $TABLE_NAME
FIELDS TERMINATED BY ','
(size, @d2, @d3, @d4, @d5, path, @d6)
SET last_modified=str_to_date(
CONCAT(@d2, ',', @d3, ',', @d4, ',', @d5), '%b,%d,%T,%Y')
我还需要设置一个名为volume
= 1的列。这就是我尝试过的:
mysql -u root --local-infile=1 home -e "
LOAD DATA LOCAL INFILE '$1'
INTO TABLE $TABLE_NAME
FIELDS TERMINATED BY ','
(size, @d2, @d3, @d4, @d5, path, @d6)
SET last_modified=str_to_date(
CONCAT(@d2, ',', @d3, ',', @d4, ',', @d5), '%b,%d,%T,%Y')
and SET volume=1;"
虽然我收到sql错误。更新volume=1
以上的核心方法是什么?
答案 0 :(得分:2)
语法应为:
mysql -u root --local-infile=1 home -e "
LOAD DATA LOCAL INFILE '$1'
INTO TABLE $TABLE_NAME
FIELDS TERMINATED BY ','
(size, @d2, @d3, @d4, @d5, path, @d6)
SET last_modified=str_to_date(
CONCAT(@d2, ',', @d3, ',', @d4, ',', @d5), '%b,%d,%T,%Y')
,volume=1;"
它应该使用标准UPDATE
语句语法,其中SET选项以逗号分隔
...
SET last_modified=blah, volume=1
正如Barmar所说,以下是有关LOAD DATA
的MySQL文档的链接:http://dev.mysql.com/doc/refman/5.1/en/load-data.html