问HN:在生产环境中运行UPDATE语句总是感觉比实际应该的要重。
我很好奇你们中有多少人有过这样的感受:
你在生产环境中。
这个变更看起来“简单”。
一个小的 UPDATE 或 DELETE 语句,带有你已经多次审阅的 WHERE 子句。
然而,就在你准备按下回车键的那一刻,心中却有一丝犹豫。
这并不是因为你不知道 SQL。
也不是因为你没有考虑清楚。
而是因为你知道:
• 如果出错,责任在你
• 回滚并不总是干净或迅速
• 而最安全的选择往往是……“别动它”
实际上,我见过人们通过以下方式来应对这种情况:
• 手动备份数据“以防万一”
• 让其他人和他们一起审视查询
• 限制谁可以执行任何操作
• 或者干脆避免直接在生产环境中修复问题
我并不是在寻求最佳实践或工具建议。
我真心想知道:
当你必须更改数据而又不能百分之百确定这不会造成问题时,你个人会怎么做?
这难道只是与生产数据库工作时不可避免的一部分吗?
查看原文
I’m curious how many of you have felt this:<p>You’re in production.
The change is “simple”.
A small UPDATE or DELETE with a WHERE clause you’ve read over multiple times.<p>Still, right before hitting enter, there’s that pause.<p>Not because you don’t know SQL.
Not because you didn’t think it through.
But because you know:
•If this goes wrong, it’s on you
•Rollback isn’t always clean or instant
•And the safest option is often… “don’t touch it”<p>In reality, I’ve seen people deal with this by:
•Manually backing up data “just in case”
•Having someone else stare at the query with them
•Restricting who’s allowed to run anything at all
•Or simply avoiding fixing things directly in prod<p>I’m not asking for best practices or tooling advice.<p>I’m genuinely curious:<p>What do you personally do, when you have to change data and can’t be 100% sure it’s harmless?<p>Is this just an unavoidable part of working with production databases?