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
INSERT
statement excludes the auto-incrementing column from the list of columns or provides aNULL
value in theVALUES
-list. You can then assign theRETURNING INTO
result from anINSERT
statement to a session-level (bind) variable. - MySQL’s …