Random
Random

Reputation: 1

Can we auto-increment a column without using trigger?

Without creating a trigger can we apply auto-increment constraint on a column in oracle sql?

Create a sequence Example:- CREATE SEQUENCE books_seq START WITH 1 INCREMENT BY 1 CACHE 10;

will this be enough to make a column auto-increment without creating a trigger??

Upvotes: 0

Views: 95

Answers (1)

Littlefoot
Littlefoot

Reputation: 142705

If you're on Oracle database version lower then 12c, then trigger is the only way to do that.

If you're on 12c and above, you can create identity column; in background, it is still a sequence, but Oracle does everything for you.

Upvotes: 1

Related Questions