After getting requests for this tutorial from our readers on this topic, we decided to do a post on it.
According to the request the task was to import a CSV file to MySQL DB.
So for that first, I went to the the main phpMyAdmin page.
Next, I clicked on the database instance that I am interested. Then, I click on the table that I want to import my data and click on Import button.
On the import form, I click Browse button to choose the CSV file on my local hard drive. Since my CSV file uses “|” to separate each fields and “\n” to separate each records, I chose the following options:
Choose CSV using LOAD DATA
Fields terminated by : ,
Fields enclosed by : [remove default value and leave it blank]
Fields escaped by : [remove default value and leave it blank]
Leave everything else to default value.
Finally, I clicked the Go button. This resulted the following SQL query.
Note, I renamed values that are specific to my environment. So this is just for your reference only.
Below is the query that you will get :
LOAD DATA LOCAL INFILE 'input_file' INTO TABLE `tablename` FIELDS TERMINATED BY ',' LINES TERMINATED
0 comments:
Post a Comment