17 October 2012

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):
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.


  1. The identity column is cool as well... :)

    I love these little improvements. Much more useful every day than a lot of the big super-features. :)



  2. What happen when the sequence is cached and cycled or reached the max value?

    1. don't know,... we'll have to wait and test when the Oracle 12c database will be available.

  3. I like little things too...thanks for sharing!!

  4. I am trying to replicate what you have done here in my oracle database 11g , it says ORA-00984 column not allowed here

    1. The feature described is an Oracle 12 feature.

  5. It wont let me create the table with the sequence as my default value for my primary key