用于模式修改的 SQL 实用程序脚本(我该怎么称呼它?)
在之前的工作中,我们有一个广泛的 SQLServer 数据库,在发布多年后不断添加新字段。我们将每个表模式存储在一个单独的纯文本文件中,其中包含 SQL create 或 alter 语句(我不记得是哪个,这让我很困扰)。当需要新列时,我们只需修改纯文本文件中的 SQL,然后将所有文件编译到一个主 .Sql 脚本中。运行脚本时,如果表不存在,它将创建该表,或者更改现有表以保留更改。从而防止任何数据丢失或需要进行任何类型的导入/导出。
我的问题是,这一切都是在我到达那里之前完成的,我没有很好的机会阅读这些实用程序并理解它们。我想为我个人重新创建这样的东西,但我不太确定它们是如何完成的。还有其他实用程序,例如存储过程和视图,但如果存根不存在,它们只会创建一个存根,然后您所要做的就是在纯文本文件中调用 Alter 。我不知道如何开始查找这个,因为在四处寻找“实践”、“技巧”或“模式”时,它似乎没有出现。有谁知道这方面的一些资源,或者可以提供一些关于让这些项目落地的见解吗?谢谢!
In a previous job we had an extensive SQLServer database that constantly had new fields being added years after release. We stored each table schema in a seperate plain text file that contained a SQL create or alter statement ( I can't remember which and that's bothering me ). When the need came for a new column, we would simply modify the SQL in the plain text file before compiling all the files into one master .Sql script. When the script was run it would either create the table if it didn't exist or alter the existing one to preserve the changes. Thus preventing any dataloss or the need to do any sort of importing/exporting.
My issue is that it was all done before I was there and I didn't get a good chance to read over the utilities and understand them. I'd like to recreate something like this for my own personal us, but I'm not quite sure how they were done. There were utilities for other things like stored procedures and views, but those would just create a stub if it did not exist and then all you had to do was call Alter in the plain text file. I am not sure how I can even begin looking this up since it didn't seem to come up when looking around for "practices", "tips", or "patterns." Does anyone know of some resources for this or can shed some insight into getting these off the ground? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您搜索“持续数据库集成”,您应该可以找到您正在寻找的内容。
If you google for "Continuous Database integration" you should find what you're looking for.