sql代码格式化_使用SQL格式化程序选项管理SQL代码格式化

sql代码格式化

This article will provide a review of SQL code formatting using the SQL formatter options in SSMS

本文将对使用SSMS中SQL格式器选项SQL代码格式进行回顾。

Nobody likes to read a large amount of text, even when it’s just a plain one. When reading SQL script where there is a large amount of non-formatted SQL code, the problem becomes even bigger.

没有人喜欢阅读大量文本,即使只是普通文本也是如此。 在读取包含大量未格式化SQL代码SQL脚本时,问题会变得更大。

SQL code can have different SQL formatting styles, which could make a job either easier or more difficult. It can make code difficult to unscramble and understand. A clean SQL can be read faster than an inconsistently written SQL; SQL reviewing and troubleshooting are more efficient; joint development efforts are more effective; handing off projects from one team to another is easier.

SQL代码可以具有不同SQL格式样式,这会使工作变得更容易或更困难。 它会使代码难以理解和理解。 与编写不一致SQL相比,干净SQL的读取速度更快。 SQL检查和故障排除效率更高; 共同发展的努力更加有效; 将项目从一个团队移交给另一个团队更容易。

How to make code readable so that it is enough just to skim through the code and get the general idea.

如何使代码具有可读性,以便仅浏览代码并获得一般想法就足够了。

It’s the SQL formatter that makes the difference.

是SQL格式化程序才有所作为。

All SQL code can be formatted manually, which is very time consuming but 3rd party SQL formatter tools do exist and can be used to help formatting quickly and efficiently.

所有SQL代码可以手动进行格式化,这是非常费时,但第三方 SQL格式化工具确实存在,可以用来帮助快速高效地格式化。

This article will guide you through some SQL formatter options via SSMS and using 3rd party SQL formatting tool such is ApexSQL Refactor to format code.

本文将指导您完成一些SQL格式化选项通过SSMS和使用第三方 SQL格式化工具,是ApexSQL重构格式化代码。

So, let’s first start with SQL formatter options to format code and then ApexSQL Refactor add-in to do the same thing and more.

因此,让我们首先开始使用SQL格式化程序选项来格式化代码,然后再使用ApexSQL Refactor加载项执行相同的操作,甚至更多。

Indenting

缩进

In SQL Server, three are three options for indenting of SQL code.

在SQL Server中,三个是用于缩进SQL代码的三个选项。

To select desired indenting options, go to the SSMS Tools menu and, from the context menu, choose the Options command:

要选择所需的缩进选项,请转到SSMS 工具菜单,然后从上下文菜单中选择选项命令:

SSMS options

In the Options window, click the Text Editor tab and under the All Languages sub-tab, select the Tabs tab:

在“选项”窗口中,单击“ 文本编辑器”选项卡,然后在“ 所有语言”子选项卡下,选择“ 选项卡” 选项卡:

SSMS indenting options

  • None 没有

When this option is selected, in a query editor, when the enter key from the keyboard is pressed, the cursor goes to the beginning of the next line:

选择此选项后,在查询编辑器中,当按下键盘上的Enter键时,光标将移至下一行的开头:

SSMS indenting options - none
  • Block

When this option is selected, in a query editor, when press the enter key, the cursor aligns the next line with the previous line:

选中此选项后,在查询编辑器中,按Enter键时,光标会将下一行与上一行对齐:

SSMS indenting options - block
  • Smart 聪明

By default, this option is used. It determines the appropriate indenting style to use.

默认情况下,使用此选项。 它确定要使用的适当缩进样式。

In the Tabs tab, it can be specified how many spaces compose a single indentation or tab, and whether the Editor uses tabs or space characters when indenting.

在“ 制表符” 选项卡中,可以指定组成一个缩进或制表符的空格数量,以及在缩进时编辑器是使用制表符还是空格字符。

If tab characters for indent and tab operations is needed, select the Keep tabs radio button:

如果需要缩进和制表符操作的制表符 ,请选择“ 保留制表符”单选按钮:

SSMS text editor options - tabs

But if want to use space characters for indent and tab operations, choose the Insert spaces radio button:

但是,如果要使用空格字符进行缩进和

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值