OOW 2012: Little things make me happy defaultSequence

OOW 2012: Little things make me happy

Yesterday evening we had the annual “We went to OOW and this is what’s new in the world we call Oracle” at AMIS.
Starting around 5pm and ending around 10pm a lot of information was presented by several AMIS colleagues.

My contribution to the evening was (amongst others) a little bit of new features in SQL and PL/SQL, only a little bit as there is too much to cover in just 20 minutes.


It’s the little things that make me happy. What is the little thing that I like?

When you define a table you can assign a default value to a column (here it comes) based on a sequence.
Take a look at the following (taken from the presentation Tom Kyte did during OOW):
OOW 2012: Little things make me happy defaultSequence
First a sequence is created, with the resounding name S. Next the table (named T) is created where the column X has a default based on the NEXTVAL of the sequence S.

Just to repeat the line of interest:

x int default s.nextval primary key

How cool is that?

No longer will you need to create a trigger to fill the column with the nextvalue from a sequence, you just declare it this way and you’re done.

Maybe it’s just syntactic sugar, I don’t know (yet) and frankly I don’t care. I like the fact that this feature makes it more declarative to populate the primary key (or any other column of course).


I’m happy.