Contents

Dbeaver 使用變數 做SQL 範本 和查詢設定 title

Dbeaver 使用變數 做SQL 範本 和查詢設定 title

Dbeaver 使用變數

1
2
3
4
5
6
7
@set a = '1'
@set b = '1'


SELECT :a FROM dual;

SELECT :b FROM dual;

按下https://i.imgur.com/atqu9d0.png

可查多個查詢
https://i.imgur.com/9zh6NIk.png

sql developer 使用變數方法(番外)

1
2
define abc=1;
select * from dual where rownum=&abc;

設定查詢標籤

一般我們維運不可能只查一次SQL
多個SQL執行,標籤不好分辨是什麼
我有查到使用方式

1
2
3
4
5
6
7
8
@set a = '1'
@set b = '1'

-- title: test1
SELECT :a FROM dual;

-- title: test2
SELECT :b FROM dual;

https://i.imgur.com/PGldd2H.png

參考: mysql - Is there a way to define the names of the result tabs names in an SQL Script in DBeaver? - Stack Overflow