有没有办法在不知道数据库类型的情况下检测 SQL 方言? [英] Is there a way to detect SQL Dialect without knowing the database type?

查看:75
本文介绍了有没有办法在不知道数据库类型的情况下检测 SQL 方言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Dbeaver 通过 ODBC 连接到数据库.我不知道它是什么类型的数据库.它可能是专有的.谁知道?

I'm using Dbeaver to connect via ODBC to a database. I have no idea what type of database it is. It might be proprietary. Who knows?

有没有办法找出要使用的 SQL 方言?LIMIT 语句不起作用,我不想通过整天选择 * 来破坏事物.

Is there a way to figure out what dialect of SQL to use? LIMIT statements aren't working, and I don't want to destroy things by selecting * all day long.

我尝试了其他几种方法来限制结果 - https://en.wikipedia.org/wiki/Select_(SQL)#Limiting_result_rows - 但我找不到有效的选项.

I've tried a couple other ways to limit results - https://en.wikipedia.org/wiki/Select_(SQL)#Limiting_result_rows - but I couldn't find an option that worked.

提前致谢!

推荐答案

假设您正在执行此数据库服务器识别一次,您可以发出查询以查看哪些工作或无法确定数据库服务器类型.

Assuming you are doing this database server identification one time, you can issue queries to see which ones work or fail to determine the database server type.

对于SQL Server,有很多比如选择@@变量之一选择@@version.

For SQL Server, there are many such as selecting one of the @@ variables Select @@version.

对于 Oracle,Select 1 FROM DUAL;

这两个查询都不会修改任何数据,应该会快速运行.其他数据库服务器也有类似的其他服务.

Both queries do not modify any data and should run quickly. There are equivalent others for other database servers.

还可以查看连接字符串并找出正在使用的数据库驱动程序类型.

One could also look at the connection string and find out what type of database driver is being used.

这篇关于有没有办法在不知道数据库类型的情况下检测 SQL 方言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆