Vivek
Vivek

Reputation: 43

how to Export data from csv file into mysql database?

how to Export data from csv file into mysql database? is there any Query or some othr way avial?

Upvotes: 3

Views: 3130

Answers (2)

divyabharathi
divyabharathi

Reputation: 2237

To Export data to csv from Mysql use this

SELECT *
INTO OUTFILE '/tmp/tablename.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM tablename

To import csv to Mysql use this

LOAD DATA INFILE 'c:/tablename.csv' INTO TABLE tablename

Upvotes: 1

John Woo
John Woo

Reputation: 263683

I think you mean IMPORT., here's how:

load data local infile 'yourCSVfilepath.csv' into table tableNameHERE
fields terminated by ','
optionally enclosed by '"'
lines terminated by '\r\n'

Upvotes: 2

Related Questions