管理解决方案中的数据库脚本
我通常在 Visual Studio 中创建一个解决方案文件夹并将我的数据库脚本放入其中。我总是至少使用这组脚本:
- 删除模型
- 创建模型脚本
- 用户函数
- 存储过程
- 静态数据(查找表)
- 测试数据(未部署)
然后我只需将它们组合起来并针对 SQL Server 运行,这样我就能够重新创建一步即可完成整个数据库(通过将这些脚本组合成一个脚本并执行它)。
反正。我从未在
- Visual Studio 或
- SQL Management Studio
中使用过项目我尝试过在 Visual Studio 2010 中创建 SQL Server 2008 数据库项目,但不知怎的,我对所有可能的服务器设置感到不知所措(无论如何,我更喜欢保留服务器上设置的默认值)。所以我有点困惑:我应该使用这个项目模板还是应该做我一直做的同样的事情?
你使用什么以及为什么?使用其中任何一个我可以受益于哪些优势?
I usually create a solution folder in Visual Studio and put my DB scripts in them. I always use at least this set of scripts:
- Drop model
- Create model script
- User functions
- Stored procedures
- Static data (lookup tables)
- Test data (not deployed)
Then I simply combine them and run against an SQL Server so I'm able to recreate the whole DB in a single step (by combining these scripts into a single one and executing it).
Anyway. I've never used projects in either:
- Visual Studio or
- SQL Management Studio
I've tried creating SQL Server 2008 Database Project in Visual Studio 2010, but I'm somehow overwhelmed by all the possible server settings (which I prefer to stay default as set on the server anyway). So I'm a bit confused: Should I use this project template or should I just do the same thing I always did?
What do you use and why? What are advantages I may benefit from by using either?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我是你,我会继续按照你现在的方式去做。事实上我愿意!在我看来,将实际的 .sql 文件放在一个文件夹中供您使用/编辑/查看的优势远远好于使用数据库项目所获得的优势。如果您正在做类似存储报告之类的事情,那么您必须与 8 个数据库进行通信,然后与 8 个不同的数据库进行比较并保存结果集等,那么就会使用 DB 项目...现在不要误会我的错误,数据库有很多优点项目,我只是认为当你有这样一个简单的设置并且已经可以工作时,它们实际上并没有多大帮助。
SQL Server 2008 的优点VS10 中的数据库项目:
从您当前使用的客户
与您的 SQL 服务器通信。
将数据库设计成源代码
控制,并保持最新状态。
数据库,反之亦然。 (这使得保持数据库最新变得非常容易,无论您在何处进行更改:文件系统数据库项目,还是物理数据库本身)
直接在数据库上进行单元测试
不使用抽象。
If I were you I would continue to do it the way you are doing it. In fact I do! The advantages of having the actual .sql files right there in a folder for you to use/edit/look at in my opinion are far better than the advantages you get by using a DB project. DB Project would be used if you were doing something like Storage Reports, were you have to communicate with like 8 databases and compare then to 8 different databases and save result sets etc... Now don't get my wrong there are advantages of Database Projects, I just don't think they are actually doing much help when you have such a simple setup that works already.
Advantages of the SQL Server 2008 Database Project in VS10:
from your current client you use to
communicate with your SQL server.
engineer a database into source
control, and keep it up to date.
databases and vice-versa. (This makes it pretty easy to keep your database up to date, no matter where you make change it: file system database project, or in the physical database itself)
unit tests directly on the database
without using abstractions.
如果您正在寻找不太复杂的东西,您可能需要尝试SQL Source Control。这甚至不需要您维护脚本,因为它不需要您在幕后进行。然而,只有当您使用 TFS 或 SVN 时,它才可以作为您的解决方案。它的售价为 295 美元...
它有 28 天的试用期,所以如果您愿意尝试,我会对您的反馈感兴趣。
If you're looking for something a little less complicated, you might want to try SQL Source Control. This won't even require you to maintain scripts, as it doesn't this for you behind the scenes. It will, however, only work as a solution for you if you use either TFS or SVN. And it costs $295...
It has a 28-day trial period, so if you're happy to try it out, I'd be interested in your feedback.