top | item 34183198

(no title)

jooz | 3 years ago

Some real life problems using standard SQL are:

- UPDATE does not return number of rows updated.

- There is no "upsert"

- There is no "merge"

- List all tables and explain command are not standard.

Do you plan to cover them on your project ?

discuss

order

ttfkam|3 years ago

SQL standards are a weird thing. Rather than wait for a spec and then get implementers like in the browser space (for the most part), SQL vendors will solve a particular customer's problem, submit their solution to the standards body, the committee will tweak the syntax for best coherence with the existing spec, and then other implementers may emerge.

This ends up with four slightly different syntaxes and the one that matches the standard wasn't even the one that proposed the feature in the first place! It is what it is. Bottom line: "close enough" is as good as it gets in the database arena, so choose your implementation wisely and go all in.

With that out of the way:

  • Multiple vendors support RETURNING from both INSERT and UPDATE statements.

  • Upserts exist with most vendors, typically with the ON CONFLICT DO variant.

  • Most support MERGE now in the latest versions.

  • I don't know of any popular database that lacks support for INFORMATION_SCHEMA queries, so listing all tables is in fact both in the standard and supported by all popular implementations.

aerzen|3 years ago

- PRQL is focused on analytical queries and it does not support DML (yet at least, see https://github.com/PRQL/prql/issues/1092). Thus there is no UPDATE or "upsert"

- What is merge? How is it different from join? How is it different from union?

- SQL does define `information_schema`, which can be used to list tables and columns. We had ideas about introspection and listing tables, but this is not on the roadmap yet. A probable outcome here will be improvements to tooling so you will be able to find tables via autocomplete (LSP).

- There are no plans for EXPLAIN

dinedal|3 years ago

> What is merge? How is it different from join? How is it different from union?

I believe the author is referencing https://www.essentialsql.com/difference-merge-update/ - which you answered in your first point. There's no UPDATE support yet, therefore there's no MERGE support yet.

ttfkam|3 years ago

Merge mutates data. A join is simply a read from an associated set of data.

mritchie712|3 years ago

Almost every db I've used has `information_schema.tables`, doesn't that solve your list tables issue?