Are SQL queries limited by the DBMS used?

北慕城南 提交于 2019-12-24 19:04:34

问题


I've seen reading recently to try and understand initially what the difference was between SQL and MySQL, and I encountered a useful quote from another post "Basically, MySQL is one of many books holding everything, and SQL is how you go about reading that book.".

Depending on the backend used, i.e MySQL vs PostgreSQL. Can a SQL query suddenly not become valid?

In particular, relational DBMS vs non-relational DBMS?


回答1:


Each database implements its own dialect of the SQL language. The dialects can vary in simple ways and in fundamental ways. For instance:

  • Functions might have different names (say len() vs length()).
  • Databases might implement not implement some set of functions (such as row_number()).
  • Databases might not support common table expressions.
  • Databases might not support certain functionality, such as full outer join.

The list really goes on. You should think of SQL as a bunch of dialects. They significantly overlap each other, but each has differences -- something like the dialects of English spoken around the world.




回答2:


Yes, dialects can vary.

There are two reasons:

  1. The ISO SQL standard doesn't require to implement all features it defines. Most of the features defined in the SQL standard as so-called optional features.

  2. Some databases don't even implement the mandatory features or offer their own syntax for features where the SQL standard foresees another solution (maybe for the vendor lock-in).

I'm running a website that aims to shed light into this jungle: https://modern-sql.com/

E.g., one of the most basic features that was already present in SQL-92 (but is still an optional feature) is the VALUES clause. You can see how it is (not) supported here:

  • https://modern-sql.com/feature/values#compatibility

However, things are getting better, I hope. E.g. MariaDB (not yet mentioned on my site) introduced the VALUES clause in the recent release 10.3.



来源:https://stackoverflow.com/questions/51230828/are-sql-queries-limited-by-the-dbms-used

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