Handy MySQL Commands

Sunday, April 25, 2010 - 6:30 pm
By Colin
Bookmark and Share
To reset an auto_increment field to 1:

ALTER TABLE tbl_name AUTO_INCREMENT = 1;
To load a local csv file into an empty existing table:

LOAD DATA LOCAL INFILE ‘/completePathToLocalData.csv’ INTO TABLE tableName FIELDS TERMINATED BY ‘,’ ENCLOSED BY ‘”‘ LINES TERMINATED BY ‘\n’ IGNORE 1 LINES;

This assumes you’ve already created your empty table with the same number of fields that your csv file has.

Bookmark and Share

Leave a Reply