Skip to content

Instantly share code, notes, and snippets.

@pgtwitter
Created February 17, 2015 13:56
Show Gist options
  • Save pgtwitter/e8a45485a85df33b6cb0 to your computer and use it in GitHub Desktop.
Save pgtwitter/e8a45485a85df33b6cb0 to your computer and use it in GitHub Desktop.
DROP TABLE IF EXISTS temp_table, drop_table;
CREATE TABLE temp_table LIKE target_table;
LOAD DATA INFILE "/path/to/csvfile.csv" INTO TABLE temp_table
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES STARTING BY '' TERMINATED BY '\n';
RENAME TABLE target_table to drop_table, temp_table to target_table;
DROP TABLE drop_table;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment