Last active
March 28, 2019 20:43
-
-
Save badah/62f595c771e0fe3712a30a0e2585fd1e to your computer and use it in GitHub Desktop.
MYSQL: import csv data into table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create table with same csv headers. | |
CREATE TABLE table_name ( id mediumint(9) NOT NULL, {..}, PRIMARY KEY (id) ); | |
# Load csv into table. | |
LOAD DATA INFILE '{abspath}/my-data.csv' | |
INTO TABLE table_name | |
FIELDS TERMINATED BY ',' | |
ENCLOSED BY '"' | |
LINES TERMINATED BY '\n' | |
IGNORE 1 ROWS; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment