Solved

Script to append data into MySQL tables

Posted on 2011-03-03
1
928 Views
Last Modified: 2012-05-11
Hello,

Can you please review and provide suggestions if needed for my syntax to load data into a MySQL table without overwriting the data?  Please see my script below which I would run under mysql in command line....

--TBL_NAME
load data local infile 'tbl_name.txt'
append into table TBL_NAME
fields terminated by ':;:';
optimize table TBL_NAME;
0
Comment
Question by:cassie5643
1 Comment
 
LVL 3

Accepted Solution

by:
mwiercin earned 500 total points
ID: 35030225
Hi,

In MySQL LOAD DATA INFILE won't overwrite any data.

$ cat test.csv 
1,2
$

mysql> create table test_load ( c1 int , c2 int); 
Query OK, 0 rows affected (0.10 sec)

mysql> select * from test_load;
Empty set (0.00 sec)

mysql> load data local  infile 'test.csv' into table test_load fields terminated by ',' lines terminated by '';
Query OK, 1 row affected (0.00 sec)
Records: 1  Deleted: 0  Skipped: 0  Warnings: 0

mysql> select * from test_load;
+------+------+
| c1   | c2   |
+------+------+
|    1 |    2 | 
+------+------+
1 row in set (0.00 sec)

mysql> load data local  infile 'test.csv' into table test_load fields terminated by ',' lines terminated by '';
Query OK, 1 row affected (0.00 sec)
Records: 1  Deleted: 0  Skipped: 0  Warnings: 0

mysql> select * from test_load;
+------+------+
| c1   | c2   |
+------+------+
|    1 |    2 | 
|    1 |    2 | 
+------+------+
2 rows in set (0.00 sec)

mysql> 

Open in new window

0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
All XML, All the Time; More Fun MySQL Tidbits – Dynamically Generate XML via Stored Procedure in MySQL Extensible Markup Language (XML) and database systems, a marriage we are seeing more and more of.  So the topics of parsing and manipulating XM…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now