我想知道我可以直接读取并将.csv文件插入到我的数据库中,或者我需要逐个读取记录并将它们插入到我的数据库中。
答案 0 :(得分:1)
您可以在java程序中尝试此查询
LOAD DATA INFILE 'c:/tmp/filename.csv'
INTO TABLE tablename
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
答案 1 :(得分:0)
LOAD DATA INFILE 'file location' -- File Name e.g /tmp/test.sql
INTO TABLE tablename
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS; -- If want to ignore header