撤消对存储过程的更改 [英] undo changes to a stored procedure

查看:146
本文介绍了撤消对存储过程的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我更改了存储过程,并且在不知不觉中改写了另一位开发人员对该存储过程所做的更改。有没有办法撤消更改并恢复旧脚本?

I altered a stored procedure and unknowingly overwrote some changes that were made to it by another developer. Is there a way to undo the changes and get the old script back?

不幸的是,我没有该数据库的备份,因此排除了该选项。

Unfortunately I do not have a backup of that database, so that option is ruled out.

推荐答案

答案是,您可以将其取回,但这并不容易。所有数据库记录对它所做的每更改。您需要:

The answer is YES, you can get it back, but it's not easy. All databases log every change made to it. You need to:


  1. 关闭服务器(或至少将其置于只读模式)

  2. 完整备份服务器

  3. 获取事故发生之前返回的所有数据库日志文件的副本

  4. 还原备份到另一台服务器上

  5. 使用数据库管理工具,回滚日志文件,直到撤消事故为止

  6. 检查还原的代码在存储的过程中并将其编码回您的当前版本中

  1. Shutdown the server (or at least put it into read-only mode)
  2. Take a full back up of the server
  3. Get a copy of all the db log files going back to before when the accident happened
  4. Restore the back up onto another server
  5. Using db admin tools, roll back through the log files until you "undo" the accident
  6. Examine the restored code in the stored proc and code it back into your current version

最重要的是:在源代码控制下获取存储的过程代码

大多数人不会理解这个概念:您只能对数据库进行更改;您无法像使用应用程序代码那样回滚代码版本。要回滚,您必须进行更多更改并删除/定义存储的proc(或其他内容)。

Most people don't "get" this concept: You can only make changes to a database; you can't roll back the code version like you can with application code. To "roll back", you must make more changes and drop/define your stored proc (or whatever).

nitpickers注意:通过回滚我不是指事务回滚。我的意思是您已经进行了更改,并决定备份一台服务器,认为更改没有好处。

Note to nitpickers: By "roll back" I do not mean "transaction roll back". I mean you've made your changes and decide one the server is back up that the change is no good.

这篇关于撤消对存储过程的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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