简体   繁体   English

SQL 存储过程存储在 svn 中?

[英]SQL stored procedure stored in svn?

Is there a way to backup/track changes to SQL stored procedures in SVN or any other method for tracking changes to SQL?有没有办法备份/跟踪 SVN 中 SQL 存储过程的更改或跟踪 SQL 更改的任何其他方法? I am using SQL 2008 and am not a DBA but am in charge of a small companies database.我正在使用 SQL 2008,我不是 DBA,但负责一个小公司的数据库。

TIA, TIA,

Brian Enderle布赖恩·恩德勒

You might try Red Gate's SQL Source Control and SQL Compare to track changes.您可以尝试Red Gate 的 SQL 源代码控制SQL 比较跟踪更改。

We write procs and save them in Subversion as scripts.我们编写 procs 并将它们作为脚本保存在 Subversion 中。 You check in each version of the script and then you can easily see previos versions or do a diff between them.您签入脚本的每个版本,然后您可以轻松查看以前的版本或在它们之间进行比较。 If youwant to reduce unnecessary diffs from formatting, get a SQL formatting tool and have everyone format the same way before check in.如果您想减少不必要的格式化差异,请获取 SQL 格式化工具,并在签入前让每个人都以相同的方式进行格式化。

All SQL code should be handled this way not just procs.所有 SQL 代码都应该以这种方式处理,而不仅仅是 procs。 We store table strutures, views etc in Subversion.我们在 Subversion 中存储表结构、视图等。 Of course with tables you havea create script and then alter table table scripts for each change in order, so that you don't wipe our tables with existing data by doing a drop and recreate.当然,对于表格,您有一个创建脚本,然后按顺序为每个更改更改表格脚本,这样您就不会通过执行删除和重新创建来用现有数据擦除我们的表格。 We also script out inserts to lookup tables to make them easier to port to other servers as well.我们还编写了插入查找表的脚本,以使它们也更容易移植到其他服务器。

You can store it in svn, but it will have difficulty tracking exact changes if members of your team use different tools to write sql: postgresql seems to be particularly bad at formatting sql. You can store it in svn, but it will have difficulty tracking exact changes if members of your team use different tools to write sql: postgresql seems to be particularly bad at formatting sql. You could consider using a free formatter: Eddie Awad lists some here:您可以考虑使用免费的格式化程序:Eddie Awad 在这里列出了一些:

http://awads.net/wp/2005/12/12/format-your-sql-the-easy-way/ http://awads.net/wp/2005/12/12/format-your-sql-the-easy-way/

Committing your code to source control depends on how you arrange your projects: your scripts could exist in a "misc" folder in an eclipse/visual studio project, or directly committed to svn via TortoiseSVN.将代码提交到源代码管理取决于您如何安排项目:您的脚本可以存在于 eclipse/visual studio 项目的“misc”文件夹中,或者通过 TortoiseSVN 直接提交给 svn。

I have two suggestions for you (which I have both used myself):我有两个建议给你(我自己都用过):

  1. you can use ScriptDB in order to extract the database schema to your file system and then commit it to svn.您可以使用ScriptDB将数据库模式提取到文件系统,然后将其提交到 svn。 I actually set up a scheduled task which invokes ScriptDB every night and then commits the folder to svn (which only commits actually modified files) automatically.我实际上设置了一个计划任务,它每晚调用 ScriptDB,然后将文件夹自动提交到 svn(仅提交实际修改的文件)。

  2. If you are using VS2010 you can open a database project and synchronize it periodically with your database via the schema compare option from the data menu.如果您使用的是 VS2010,您可以打开一个数据库项目并通过数据菜单中的模式比较选项定期将其与您的数据库同步。 After that you can commit your changes via tortoiseSVN or Ankh directly from VS.之后,您可以直接从 VS 通过 tortoiseSVN 或 Ankh 提交您的更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM