PostgreSQL’s approach to automatic numbering is as simple as
Oracle but different than MySQL, and Microsoft SQL Server. For
example, you have a two-step process with Oracle, PostgreSQL,
MySQL, and Microsoft SQL Server. First, you create an Oracle
table with the GENERATED AS IDENTITY clause, a
PostgreSQL table with the SERIAL data type, a MySQL
table with the AUTO_INCREMENT clause, and a
Microsoft SQL Server table with the IDENTITY(1,1)
clause. Then, you need to write an INSERT statement
for Oracle, MySQL, or Microsoft SQL Server like:
- Oracle’s
INSERTstatement excludes the auto-incrementing column from the list of columns or provides aNULLvalue in theVALUES-list. You can then assign theRETURNING INTOresult from anINSERTstatement to a session-level (bind) variable. - MySQL’s …