SQL Pretty Printer美化SQL工具

SQL格式化插件—SQL Pretty Printer

   我们编写的SQL脚本,例如存储过程和函数等,由于在编写过程中,我们需要手动美化SQL增加可读性,需要经常调整列名,注释以及AS,要我们手动空格,费时又费力。而且手动对代码进行格式化,如果代码脚本比较多,例如JION的表比较多,那需要调整的就更多了,有这个时间我们可能又写了几段SQL,那么问题来了,如何快速对SQL Server中的代码进行格式化。
  有一个工具 SQL Pretty Printer,是一个SQL 管理工具的插件,功能非常强,格式化SQL代码效果很好,还可申请免费注册码,就下载下来试用了一下,感觉非常不错。这里给大家分享一下。
  下载并安装SQL Pretty Printer Add-In for SSMS V3.6.1 后,在SQL Server 2008 管理工具中可以看到SQL Beautifier的菜单:

例如我们原本的代码

select 
unix_timestamp() as etl_time,   --时间      
order_id as order_id,
app_id as app_id,    --ID         
status as status,   
coupon_id as coupon_id,       
coupon_deduct_amt as coupon_deduct_amt,  
coupon_status as coupon_status    
from stg_xyz_app_order_link_ed a --表名
where dt = '20200105';

 

格式化之后,我们不仅对齐了as列 而且使每个字段加入了我们的列名,简直是非常方便了

 

select unix_timestamp()    as etl_time,         --时间     
       a.order_id          as order_id,
       a.app_id            as app_id,           --ID  
       a.status            as status,   
       a.coupon_id         as coupon_id,       
       a.coupon_deduct_amt as coupon_deduct_amt,  
       a.coupon_status     as coupon_status    
from stg_xyz_app_order_link_ed a                --表名
where a.dt = '20200105';

是不是非常规整,漂亮呢?!
SQL Pretty Printer目前提供4种使用方式,桌面版本,SSMS(SQL Server Management Studio)插件,VS插件,和提供API接口。
下载链接:http://www.dpriver.com/dlaction.php
在线版本(不支持中文):http://www.dpriver.com/pp/sqlformat.htm
获取免费的授权码:http://www.dpriver.com/products/sqlpp/getforfree.php

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值