Thursday, July 12, 2012

Importing CSV file into MySQL



Importing CSV file into MySQL

Some computer users have excel file with important data stored with, later when development of database applications they need to import those data into database.You would have to save xls files as csv files using excel.example file I have created as follows.


After creating above data2.csv file create table called vehicle_type using the field same as in data2.csv as bellow.
CREATE TABLE IF NOT EXISTS `vehicle_type` (
  `ID` int(40) NOT NULL AUTO_INCREMENT,
  `Type` varchar(40) NOT NULL,
  `Number` varchar(40) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

Then open phpmyadmin page(I use XAMPP)


After that click browse and find your data2.csv.Field Terminated by=,and Column names=ID,Type,Number keep the other settings as bellow.


 Now Press the Go button then you will get the following result.


No comments:

Post a Comment