Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
165 views
in Technique[技术] by (71.8m points)

How can I update table, if table exists with MySQL info?

I have a mysql broken database and I have another one which is good and with all tables and columns. How can I import in broken database only missing info which is in good database? I mean tables and columns and values not stored info.

I exported good database and when I try to import in broken database I get: #1060 - Duplicate column name 'id_advice'

So, what I need is to skip if duplicate items and continue to add only info which does not exist.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can make use of Mysqldump. There is a selection to use no data.

mysqldump -uYourUserName -p=YourPassword databasename --no-data --routines > "dump.sql"

The you can import the table stucture. there is also different options to use create if not exists or drop if exists so you can tailor make it for your needs. I recommend downloading Mysql Workbench, its easily done with that tool.

Info about mysqldump http://dev.mysql.com/doc/refman/5.6/en/mysqldump.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...