1

In SQL Server it requires certain option to be ON to insert value in ID column – SET IDENTITY_INSERT table ON.

Could someone help me with the Oracle equivalent? Or will Oracle allow ID value to be inserted by default?

What should we replace SET IDENTITY_INSERT table ON/OFF with in Oracle?

  • Which Oracle version are you using? And how did you define the primary key? Please **[edit]** your question and add the complete `CREATE TABLE` statement for the table in question. –  Feb 05 '20 at 06:55

1 Answers1

0

Oracle 12c finally introduced a proper notion of identity columns (instead of having to manually manage a sequence). Instead of turning it on or off as you in SQL Server, you can just define the table that way:

CREATE TABLE mytable (
    id NUMBER GENERATED BY DEFAULT AS IDENTITY
    -- other columns you need...
)
Mureinik
  • 297,002
  • 52
  • 306
  • 350