Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Inserting 00001 into a table

 
Mahesh Lohi
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

In one of my application I would want to insert 0000001 into the table.

Once I increment it it should be 0000002. Is this posible.

Thank you in advance

 
Evan Caballero
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What type of database do you use ?

 
Mahesh Lohi
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the quick response. I use mysql.
 
Campbell Ritchie
Marshal
Posts: 53126
124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you want this to be a primary key with auto_increment properties?
 
Mahesh Lohi
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes if possible. not a prob if that is not possible. I will increment it each time by my self.
 
Evan Caballero
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ritchie is right, you should set the auto-increment property to true in the column definition of the table you are trying to insert to.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!