如何在Java中复制SQL并粘贴到Dbeaver中。

huangapple go评论50阅读模式
英文:

How to copy SQL in Java and paste it in Dbeaver

问题

DBeaver是一个访问数据库的优秀工具。但在版本23(我的电脑上是23.1.1),出现了一些问题。

在升级之前,我使用的是版本20到21。有一个令人钦佩的功能,可以通过一些字符串处理函数在Java代码中复制SQL,但当粘贴到DBeaver时,它会变成纯SQL。

例如:

StringBuilder sb = new StringBuilder();
sb.append(" select * from myTable ");
sb.append(" where name is null or lastName = 'Jake' ");

您可以从第一个引号复制到最后一个引号,包括sb.append()

它将是:

select * from myTable 
where name is null or lastName = 'Jake'

在最新版本中是否有实现这个功能的方法?
我希望这个功能没有被故意移除,当编写大型SQL时,它真的很有帮助。

英文:

Dbeaver is a great tool for accessing database. But in ver.23 (23.1.1 in my PC), something goes wrong.

Before upgrading it, I'm using ver.20~21. There's a admirable function makes you be able to copy SQL in java code with some String processing function, but when it be paste to DBeaver, it'll be pure SQL.

As an example :

StringBuilder sb = new StringBuilder();
sb.append(" select * from myTable ");
sb.append(" where name is null or lastName = 'Jake' ");

You can copy from the first quote to the last one, including "sb.append()"

" select * from myTable ");
sb.append(" where name is null or lastName = 'Jake' "

And it will be :

select * from myTable 
where name is null or lastName = 'Jake'

Is there any way to achieve this in the latest version?
I hope this function isn't removed by purpose, it really hepls when writing huge sql.

答案1

得分: 1

去到 Window -> Preferences -> Editors -> SQL Editor -> Code Editor
勾选选项 '从源代码提取 SQL'

链接:https://github.com/dbeaver/dbeaver/issues/240#issuecomment-198987695

英文:

Had the same problem, this helped me.

Go to Window -> Preferences -> Editors -> SQL Editor -> Code Editor

Check the option 'Extract SQL from Source'

https://github.com/dbeaver/dbeaver/issues/240#issuecomment-198987695

huangapple
  • 本文由 发表于 2023年7月11日 14:38:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/76659262.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定