|
|
|
|
|
by chasil
999 days ago
|
|
MERGE is standardized in ANSI SQL 2003, and updated in 2008: https://en.wikipedia.org/wiki/Merge_(SQL) No question, everyone should use standardized, cross-platform syntax if at all possible. Maybe someday ANSI will standardize some kind of upsert syntax; until that time use upsert only if you are explicitly tying your SQL to your particular database. |
|
There are big questionmarks around this statement. SQL isn't an interchange format. Standard table design goes a long way because data has lots of different consumers and needs frequently to be moved around between systems, standard SQL is nothing useful to aim for. Everyone already uses DB-specific drivers and syntax because it is better than the alternative.
- The standard is not generally available. Most of us will never learn what is in it.
- SQL standardises terrible syntax. The SQL standards committee has a unique view on programming where "function_name(a, b, c);" is some sort of weird alternative syntax. They haven't gotten as far as working out variables or function composition either [0].
- Tying SQL to your specific database is the best option for performance. Writing database-independent SQL is somethign of a fools errand, it is either trivial performance-insensitive enough that you should be using a code generator or complex enough to deserve DB-specific turning.
[0] I assume. Not going to pay for a copy of the standard to check.