从SQL备份文件更新1列 [英] Update 1 column from sql backup file

查看:62
本文介绍了从SQL备份文件更新1列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在名为signals的数据库中有一个表srSignals,看起来像这样:

I have a table srSignals, in a database called signals that looks like so:

animal      inserttime              id
dog         1970-00-00 00:00:00     3042
cat         1970-00-00 00:00:00     3041
monkey      1970-00-00 00:00:00     3040
hamster     1970-00-00 00:00:00     6

我所有的inserttime值都因意外而重置为1970.幸运的是,我具有正确的inserttime值(和相应的id值)的数据库signals的备份.备份文件称为signals.sql.gz(显然,在gz压缩中带有signals.sql).

All of my inserttime values got reset to 1970 on accident. Luckily I have a backup of the database signals with the correct inserttime values (and corresponding id values). The backup file is called signals.sql.gz (with signals.sql inside the gz compression, obviously).

我的问题是:使用phpMyAdmin,我如何updateinserttime,其中现有表的id =备份文件的id.请注意,由于在此期间其他内容已添加到数据库中,因此我不想完全还原该表.

My question is this: using phpMyAdmin, how can I update the column inserttime where the id of the existing table = the id of the backup file. Note that I do NOT want to completely restore the table as other stuff has been added to the database in the interim.

我不确定实现此目的的最佳方法-恢复phpMyAdmin的功能吗?一些花哨的更新/加载?

I'm not sure the best way to get about this - restore functionality of phpMyAdmin? Some fancy update / load?

谢谢!

推荐答案

将备份还原到其他数据库,然后进行更新:

Restore the backup to a different database and then do an update:

UPDATE database1.table, database2.table
SET database1.table.field = database2.table.field
WHERE database1.table.idfield = database2.table.idfield

这篇关于从SQL备份文件更新1列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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