wondering if the ANSI SQL standard has a portable way to create a sequence object and get values from it?
I can't find a portable way, but search engines seem to confuse ANSI sql with MS SQL server, so maybe I'm just missing it...
-
Can you define what you mean by "portable"?J.D.– J.D.2024年09月09日 12:13:04 +00:00Commented Sep 9, 2024 at 12:13
-
Sure, I mean portable across database platforms. It's why I'm asking for ANSI sql. I can write a join with ANSI syntax and it'll work on any ANSI compliant DB, so it's portable.mikeb– mikeb2024年09月09日 13:43:04 +00:00Commented Sep 9, 2024 at 13:43
-
Fair enough. Endrju's answer is what I was going to say, if that's the case. Essentially there is no single portable syntax or even feature across all of the main RDBMS.J.D.– J.D.2024年09月09日 22:21:47 +00:00Commented Sep 9, 2024 at 22:21
1 Answer 1
The CREATE SEQUENCE
statement is defined in ANSI SQL:2003 which is unfortunately not freely available. There's an overview of new features which describes sequences. As for the portability, it varies. For example SQLite and MySQL don't implement it, but Oracle, SQL Server, PostgreSQL, IBM DB2 do. Basic syntax is the same, but for example Oracle some more options.
So it's not universally portable. You need to define engines that you want to support.