撤消对存储过程的更改 [英] undo changes to a stored procedure
问题描述
我更改了存储过程,并且在不知不觉中改写了另一位开发人员对该存储过程所做的更改。有没有办法撤消更改并恢复旧脚本?
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:
- 关闭服务器(或至少将其置于只读模式)
- 完整备份服务器
- 获取事故发生之前返回的所有数据库日志文件的副本
- 还原备份到另一台服务器上
- 使用数据库管理工具,回滚日志文件,直到撤消事故为止
- 检查还原的代码在存储的过程中并将其编码回您的当前版本中
- Shutdown the server (or at least put it into read-only mode)
- Take a full back up of the server
- Get a copy of all the db log files going back to before when the accident happened
- Restore the back up onto another server
- Using db admin tools, roll back through the log files until you "undo" the accident
- 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屋!