Tuesday, 25 December 2012

How to upload CSV file using Toad for MySql


-- Conditionally drop the table.
DROP TABLE IF EXISTS excelupload;

-- Create the new upload target table.
CREATE TABLE excelupload
( ticket   int(20)
, remarks varchar(500) ) ENGINE=MEMORY;

-- Load the data from a file, don't forget the \n after the \r on Windows or it won't work.
LOAD DATA INFILE 'f:/tickettoclose.csv'
INTO TABLE excelupload
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\r\n';

-- Select the uploaded records.
SELECT * FROM excelupload;

No comments:

Post a Comment