Monday, 6 June 2016

Oracle Database 11g How To Set "Auto Increment"

Hello everbody!

Setting auto increment property in Oracle 11g is a little bit different from way that I am used to with other databases. There is no such keyword as auto_increment in Oracle 11g. We have to achieve it by using the codes below.



STEP 1 - Connect and Grant

First of all you need to connect with the user. This user has to be granted necessary resources. So make sure your user has the permission to create an manage tables.

STEP 2 - Create a Table

STEP 3 - Define a Primary Key


STEP 4 - Create a Sequence


STEP 5 - Create a Trigger That Will Increment The ID


Remind that Oracle 12c now has new features to make this easier. So if you are using Oracle 12c, this will probably not be useful for you.

Hope to see you in the next blog post!

Selen

No comments:

Post a Comment