为 t-sql 命名存储过程的最佳实践是什么? [英] What's the best practice of naming stored procedure for t-sql?

查看:34
本文介绍了为 t-sql 命名存储过程的最佳实践是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用过几个大型数据库,存储过程的名称非常不同:

I have worked with several big databases and the names of stored procedures were very different:

SP_PrefixXXX
PrefixYyyXxx
Prefix: Rep, Act

命名的最佳做法是什么?如何以适当的方式组织它们?

What's the best practice of naming? How can I organize them in a proper way?

推荐答案

sp_ 前缀代表系统过程,它应该用作常规过程的前缀.如果这样做,它每次都会首先额外访问 master 数据库以查找过程,如果它与那里的过程之一具有相同的名称,则将执行该过程而不是你的程序.

The sp_ prefix stands for System Procedure, and it should not be used as prefix for regular procedures. If you do, it will first make an extra trip to the master database each time to look for the procedure, and if it would have the same name as one of the procedures there, that procedure will be executed instead of your procedure.

除此之外,您可以随意制定任何您喜欢的命名约定.我们公司使用的一种是subsystem_object_action,例如main_Customer_Get.这会将属于彼此靠近的过程放在列表中.

Other than that, you are free to make up any naming convention you like. One used by our company is subsystem_object_action, e.g. main_Customer_Get. That puts procedures that belong together close to each other in the listing.

这篇关于为 t-sql 命名存储过程的最佳实践是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆