问题
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()
vslength()
). - 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:
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.
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