Is there an ANSI standard for auto-numbered columns.

Currently, we have a choice of SERIAL, AUTOINCREMENT, AUTO_INCREMENT, IDENTITY() and good old NEXTVAL() among others.

I read somewhere that there is a new standard using IDENTITY which I know that Oracle has recently implemented. I know that Oracle is hardly the last word on standards.

If there is a standard, then it’s a long time coming.

1 Answer 1


Yes there is, and it's definitely not "a new standard". It's been in the SQL standard since SQL:2003

The definition is:

<identity column specification> ::=
    [ <left paren> <common sequence generator options> <right paren> ]

The optional part with the sequence generator options lets you define the characteristics of the underlying sequence (=generator), you could do something like:

id integer GENERATED ALWAYS AS IDENTITY (start with 42 increment by 10 cycle)

This syntax is supported (at least) by PostgreSQL 10, Oracle 12.1, DB2, Apache Derby, HSQLDB, Firebird and NuoDB.

  • 1
    Ah, thank you. The SQL:2003 was just what I needed to find more information. I found this link: sigmodrecord.org/publications/sigmodRecord/0403/…. I don’t think it’s widely supported, is it?
    – Manngo
    Commented Feb 20, 2017 at 6:48
  • 1
    @Manngo: I know that Oracle 12c, DB2, Derby, HSQLDB, NuoDB and Firebird support that syntax. There is some discussion of adding this to Postgres, but it doesn't seem to be on the roadmap for version 10
    – user1822
    Commented Feb 20, 2017 at 6:58
  • So, none of the databases I use myself. Thanks again!
    – Manngo
    Commented Feb 20, 2017 at 7:00
  • 1
    @a_horse_with_no_name seems like it found its way into Postgres 10!: wiki.postgresql.org/wiki/New_in_postgres_10#Identity_Columns Commented Sep 25, 2017 at 10:45
  • 1
    I confirmed it works on postgres 10
    – deFreitas
    Commented Aug 26, 2018 at 23:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.