如果表存在 MySQL 信息,如何更新表? [英] How can I update table, if table exists with MySQL info?

查看:63
本文介绍了如果表存在 MySQL 信息,如何更新表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 mysql 损坏的数据库,我有另一个很好的数据库和所有表和列.如何在损坏的数据库中仅导入良好数据库中缺少的信息?我的意思是表、列和值没有存储信息.

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.

我导出了良好的数据库,当我尝试导入损坏的数据库时,我得到:#1060 - 列名重复'id_advice'

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.

推荐答案

您可以使用 Mysqldump.可以选择不使用数据.

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

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

您可以导入表格结构.还有不同的选项可以使用如果不存在则创建或如果存在则删除,以便您可以根据自己的需要进行定制.我建议下载 Mysql Workbench,使用该工具可以轻松完成.

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.

关于mysqldump的信息http://dev.mysql.com/doc/refman/5.6/en/mysqldump.html

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

这篇关于如果表存在 MySQL 信息,如何更新表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆