Skip to content
Advertisement

Retrieve Oracle last inserted IDENTITY

Since Oracle 12c we can use IDENTITY fields.

Is there a way to retrieve the last inserted identity (i.e. select @@identity or select LAST_INSERTED_ID() and so on)?

Advertisement

Answer

Well. Oracle uses sequences and default values for IDENTITY functionality in 12c. Therefore you need to know about sequences for your question.

First create a test identity table.

First, lets find your sequence name that is created with this identity column. This sequence name is a default value in your table.

for me this value is “ISEQ$$_193606”

insert some values.

then insert value and find identity.

you should see your identity value. If you want to do in one block use

Last ID is my identity column name.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement