DBeaver如何支持变量

496 阅读1分钟

相信大家都有用过 Dbeaver吧, 没错就是那个免费又支持数据库最多的开源数据库客户端. 没有用过的朋友可以去试试, 用了两三年了, 感觉还是不错的(毕竟白剽). DBeaver Community | Free Universal Database Tool


今天在做接口耗时分析时, 定义了三条查询, 分别用来查询某个接口的最大, 最小, 平均耗时.

SELECT max(cast(request_time as float)) from slog.NginxLog nl where `path`= '/netdisk/v1/file/create-share-url' and `_time_second_` > '2022-12-01';

SELECT AVG(cast(request_time as float)) from slog.NginxLog nl where `path`= '/netdisk/v1/file/create-share-url' and `_time_second_` > '2022-12-01';

SELECT MIN(cast(request_time as float)) from slog.NginxLog nl where `path`= '/netdisk/v1/file/create-share-url' and `_time_second_` > '2022-12-01';

现在准备查另一个接口, 如果按往常, 我们可能直接把上面三条语句的 path 替换掉就好了. 想了想要是有变量就好了, 如果网上一搜果然是支持的.

dbeaver.com/docs/wiki/S…

dbeaver.com/docs/wiki/C…

只需要在设置中启用变量支持(默认是启用的), 然后在编辑器中按如下用法即可:

@set  req_path = '/netdisk/v1/file/create-share-url'

SELECT max(cast(request_time as float)) from slog.NginxLog nl where `path`= ${req_path} and `_time_second_` > '2022-12-01';