Is there a way to detect SQL Dialect without knowing the database type?

爷,独闯天下 提交于 2021-01-29 09:22:37

问题


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?

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.

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.

Thanks in advance!


回答1:


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.

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

For 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.




回答2:


Tried a few more limit-style statements and found it to be SQL Server/ Access



来源:https://stackoverflow.com/questions/58437763/is-there-a-way-to-detect-sql-dialect-without-knowing-the-database-type

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!