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.

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        |
+--------+----------+-----------+

Advertisements

 

We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.

Share on Google+Share on Google+

SQL Bulk Insert csv

Posted on: January 20, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

 

Discuss: SQL Bulk Insert csv   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads