Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Changing a Field to Auto-Generation Type after Table is already created

 
Anupama Sudhakaran
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 Pidaran
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

try adding the follwoing property in your hibernate mapping xml.

<generator class="increment">
</generator>


I think this would help you.
 
Anupama Sudhakaran
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Anupama Sudhakaran
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 unique
  • the 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
    Posts: 18
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thank you Paul
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic