| Author |
Changing a Field to Auto-Generation Type after Table is already created
|
Anupama Sudhakaran
Greenhorn
Joined: Feb 22, 2010
Posts: 18
|
|
Hello,
How do i change a Field to Auto Number type in Oracle SQL Developer after i have already created the Table?
i want to use this to map a File in Hibernate. or do i have to write some Hibernate code?
Any help would be greatly appreciated.
Thank you in advance
|
 |
Prabu Anaiyur
Greenhorn
Joined: Feb 22, 2010
Posts: 15
|
|
Hello,
try adding the follwoing property in your hibernate mapping xml.
<generator class="increment">
</generator>
I think this would help you.
|
 |
Anupama Sudhakaran
Greenhorn
Joined: Feb 22, 2010
Posts: 18
|
|
|
i did that but when im trying to put "native" as the generator class, its starting from any number like 21 or 41. i though tit must start from 1. is it not like that?
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
Anupama Sudhakaran wrote:i did that but when im trying to put "native" as the generator class, its starting from any number like 21 or 41. i though tit must start from 1. is it not like that?
Why must it start from one? Does your primary key also have business meaning?
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Anupama Sudhakaran
Greenhorn
Joined: Feb 22, 2010
Posts: 18
|
|
|
no it doesnt. i am writing small programs a si have just started learning Hibernate. in Access, when we select auto number for a field, it usually begins with 1 and keeps incrementing. does it not happenlike that in Oracle?
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
No. Sequences are usually used in Oracle to back primary key generation, so all you really need to know from these is:
the number is uniquethe numbers are in order
You get the same semantic meaning from 1,2,3,4 as you get from 1,45,877,678768. However there is a performance cost in keeping sequence numbers consecutive. Without any benefit, why do it?
|
 |
Anupama Sudhakaran
Greenhorn
Joined: Feb 22, 2010
Posts: 18
|
|
|
Thank you Paul
|
 |
 |
|
|
subject: Changing a Field to Auto-Generation Type after Table is already created
|
|
|