Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Append MYSQL dump to a table

I am getting two different dumps from two databases , All i need to do is , i need to append dump in to a single table , is this possible in mysql ..?

ex:- consider two sql files , first.sql file , second.sql file .

First.sql File has

name  date
name1 2013-06-01
name2 2013-06-01

second.sql file has

name  date
name3 2013-06-01
name4 2013-06-01

i would have to append them in a single table .

Final table

name  date
name1 2013-06-01
name2 2013-06-01
name3 2013-06-01
name4 2013-06-01

dump restore does truncate load

, i would like to append data at each sql restore command .

like image 790
Surya Avatar asked Jul 01 '13 04:07

Surya


People also ask

Is it possible to dump a table data in MySQL?

With the utility, you can dump tables, one or several databases, or the entire server with all databases and tables along with their objects or migrate them to another server. In addition, the mysqldump utility can output the dump to the CSV or XML file formats.


2 Answers

The .sql file is a script, you can edit it, and remove the part where it creates/drops the table.

If you're using mysqldump, you can add the --skip-add-drop-table and --no-create-info options so the drop/create table instructions won't be there in the first place

You can find more info on the mysqldump documentation page

like image 168
Guillaume Avatar answered Nov 14 '22 21:11

Guillaume


mysqldump --skip-add-drop-table --no-create-info -u pentah_user -p test outtestactivity > outtestactivity1.sql

like image 23
Surya Avatar answered Nov 14 '22 21:11

Surya