Tuesday, November 24, 2020

Inserting auto IDs in Oracle

When dealing with tables with an auto-incremented ID field, Oracle requires an special syntax if you’re about to insert data manually. You must directly call the name of the sequence of that table, followed by a special field:

INSERT INTO person (id_person, name)
VALUES (sq_id_person.NEXTVAL, 'John')

Note that the name of the sequence is actually arbitrary.