SQL Bulk Insert csv
SQL Bulk Insert is used to import the records from csv file to the same format table in a Mysql database.
Understand with Example
The Tutorial covers an example from 'SQL Bulk Insert CSV'.To understand and grasp this example we create a table 'stu' with required fieldnames and datatypes respectively.Again, we create a file abc with extension csv contain the records that are imported to the table 'stu'.
Create Table Stu
Create Table Stu( Id int, Name varchar(15), Class()); |
abc.csv
1 Komal 10 2 Ajay 10 3 Santosh 10 4 Rakesh 10 5 Bhau 10 |
Backup query
The Backup query is used to import a abc.csv file into a table 'stu'.The LOAD DATA INFILE import the file abc.csv to the same format table stu of the database.
LOAD DATA INFILE 'c:/abc.csv' INTO TABLE stu FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n'; |
Table Stu_Table
+--------+----------+-----------+ | Stu_Id | Stu_Name | Stu_Class | +--------+----------+-----------+ | 1 | Komal | 10 | | 2 | Ajay | 10 | | 3 | Santosh | 10 | | 4 | Rakesh | 10 | | 5 | Bhau | 10 | +--------+----------+-----------+ |