Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Sql Mysql-example SQL Bulk Insert csv

Related Tutorials


 
 

Share on Google+Share on Google+

SQL Bulk Insert csv

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

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: January 20, 2009

Related Tutorials

Discuss: SQL Bulk Insert csv   View All Comments

Post your Comment


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