?
Solved

Script to append data into MySQL tables

Posted on 2011-03-03
1
Medium Priority
?
1,012 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
mwiercin earned 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
In this article, we’ll look at how to deploy ProxySQL.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

762 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