[英]How do I pretty format my SQL query in DBeaver?
I use DBeaver for my main IDE to query multiple databases.我使用 DBeaver 作为我的主要 IDE 来查询多个数据库。 When I query a table, it automatically generates a long select statement with all columns in one line.
当我查询一个表时,它会自动生成一个长的 select 语句,其中所有列都在一行中。
When I am making more complex queries, this gets very cumbersome to work with and read.当我进行更复杂的查询时,使用和阅读这会变得非常麻烦。 I would like to view the select values on separate lines rather than one long string.
我想在单独的行而不是一个长字符串上查看选择值。
Is there an easy way (perhaps by using Notepad++ or Sublime Text) to break up the query (with line breaks after the commas)?是否有一种简单的方法(可能通过使用 Notepad++ 或 Sublime Text)来分解查询(在逗号后使用换行符)?
For example,例如,
select name, address, city, state, country, zip_code, birthday, membership_type
from customers
to到
select
name,
address,
city,
state,
country,
zip_code,
birthday,
membership_type
from customers
Yes there is.是的。 I use Notepad++ because it is free and I use it for everything!
我使用 Notepad++ 是因为它是免费的,而且我用它做任何事! Anyways, Notepad++ has a Plugin called: Poor Man's T-SQL Formatter.
不管怎样,Notepad++ 有一个插件叫做:Poor Man's T-SQL Formatter。 It works with a click of a button.
它只需单击一个按钮即可工作。 You also get a few custom options like if you want to auto capitalize table names, etc.
您还可以获得一些自定义选项,例如是否要自动大写表名等。
Select a query to be formatted and Ctrl + shift + F does the work.选择要格式化的查询,然后Ctrl + shift + F 即可完成工作。 I am using DBeaver 6.3.0
我正在使用 DBeaver 6.3.0
there is another plugin for formatting SQL in Notepad++.在 Notepad++ 中有另一个用于格式化 SQL 的插件。 It can be found here: SQLinForm SQL Formatter and has 100+ formatting options with code folding and color formatting.
可在此处找到: SQLinForm SQL Formatter并具有 100 多个带有代码折叠和颜色格式的格式选项。 There is also a free plugin available.
还有一个免费插件可用。
In SublimeText I assume you have already installed Package Control ?在 SublimeText 中,我假设您已经安装了Package Control ? If not do so as soon as you can, it is a vital tool.
如果不尽快这样做,它是一个重要的工具。
From Package Control there are a number of options to do what you want to do.从包控制有许多选项可以做你想做的事情。 Here are some options
这里有一些选项
I would start with SqlBeautifier and then try others to find which one suits your taste best.我会从SqlBeautifier开始,然后尝试其他人来找到最适合您口味的。
使用反引号 ` 代替引号 " 或 '
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.