Home » SQL & PL/SQL » SQL & PL/SQL » Autoinc field?
Autoinc field? [message #185754] Thu, 03 August 2006 07:34 Go to next message
henrik79
Messages: 2
Registered: August 2006
Junior Member
Hi!

Is there any other ways of having an auto incrementing column than creating a sequence and a trigger?

(in oracle 9 or 10)
Re: Autoinc field? [message #185759 is a reply to message #185754] Thu, 03 August 2006 07:53 Go to previous messageGo to next message
JSI2001
Messages: 1016
Registered: March 2005
Location: Scotland
Senior Member
you can use application code
Re: Autoinc field? [message #186015 is a reply to message #185754] Fri, 04 August 2006 14:20 Go to previous messageGo to next message
Bill B
Messages: 1484
Registered: December 2004
Senior Member
No,
The only way to guarantee a UNIQUE sequence is to use a sequence. Using somthing like "select max(val)+1 from my_table" WILL fail. Wither or not you use a trigger is up to you, but it is certainly the simplest and safest way. Why don't you want to use a trigger?
Re: Autoinc field? [message #186122 is a reply to message #186015] Sun, 06 August 2006 03:57 Go to previous messageGo to next message
henrik79
Messages: 2
Registered: August 2006
Junior Member
I was just wondering if Oracle had something similar to PostgreSQLs serial, MySQLs AUTO_INCREMENT or SQL Servers IDENTITY
Re: Autoinc field? [message #186130 is a reply to message #186122] Sun, 06 August 2006 06:19 Go to previous messageGo to next message
Barbara Boehmer
Messages: 8635
Registered: November 2002
Location: California, USA
Senior Member
No, Oracle does not have an auto_increment like MySQL. A sequence and a trigger is the best way to accomplish the same in Oracle.
Re: Autoinc field? [message #186171 is a reply to message #186130] Sun, 06 August 2006 17:17 Go to previous message
William Robertson
Messages: 1640
Registered: August 2003
Location: London, UK
Senior Member
You could also look at the SYS_GUID() function, which can be used in a column default expression. I haven't tried this myself, but for some background and examples see http://feuerthoughts.blogspot.com/2006/02/watch-out-for-sequential-oracle-guids.html
Previous Topic: how can i select from subtypes?
Next Topic: EXCEPTION Woes?
Goto Forum:
  


Current Time: Wed Dec 07 12:40:07 CST 2016

Total time taken to generate the page: 0.08356 seconds