简体   繁体   English

Azure SQL服务器中常用的存储过程放在哪里

[英]Where to put common stored procedures in Azure SQL Server

I have a couple of stored procedures that will be used only for maintenance tasks (facilitating truncation of tables, rebuilding indexes etc).我有几个存储过程将仅用于维护任务(促进截断表、重建索引等)。 In my mind the natural location for these would be the master DB (or any other central DB) so that other DBs would be able share this functionality.在我看来,这些的自然位置将是主数据库(或任何其他中央数据库),以便其他数据库能够共享此功能。

This would also clarify the intent of these procedure and excludes these from DACPAC deployments.这也将阐明这些程序的意图,并将这些从 DACPAC 部署中排除。 However, in Azure SQL cross-database queries are not allowed so I do not find any natural place to put these procedures inside.但是,在 Azure SQL 中不允许跨数据库查询,所以我没有找到任何自然的地方将这些程序放在里面。

Where would you put these kinds of stored procedures that are outside the actual business needs?您会将这些超出实际业务需求的存储过程放在哪里?

You can always create a schema , eg called something like admin and put them in there.您总是可以创建一个模式,例如称为admin之类的东西并将它们放在那里。

See Create a Database Schema on Microsoft docs for more details.有关更多详细信息,请参阅 Microsoft 文档上的创建数据库架构

Then you can execute them from within the database itself, and a schema is also a great mechanism to regulate permissions - giving execute permissions on these stored procedures only to your DBA staff and now users of the regular database.然后,您可以从数据库本身内部执行它们,并且模式也是调节权限的一种很好的机制 - 仅将这些存储过程的执行权限授予您的 DBA 员工,现在是常规数据库的用户。

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

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