# Change the start of auto\_increment?

**URL:** <https://www.ruby-forum.com/t/change-the-start-of-auto-increment/162220>\
**Category:** Rails\
**Created:** [March 6, 2009, 11:38pm UTC](https://www.ruby-forum.com/t/change-the-start-of-auto-increment/162220 "2009-03-06T23:38:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![loader](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/5daacb/32.png) [@loader](https://www.ruby-forum.com/u/loader)\
**Post date:** [March 6, 2009, 11:38pm UTC](https://www.ruby-forum.com/t/change-the-start-of-auto-increment/162220/1 "2009-03-06T23:38:05Z")

</div>

Hello everyone!

I have a table, “posts”. And I want to start the id from 1000. Is that  
possible?  
Do I need a migration?

Thank your for your help!

---

<div class="post-metadata">

**Author:** ![loader](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/5daacb/32.png) [@loader](https://www.ruby-forum.com/u/loader)\
**Post date:** [March 7, 2009, 12:59am UTC](https://www.ruby-forum.com/t/change-the-start-of-auto-increment/162220/2 "2009-03-07T00:59:37Z")

</div>

What database? If it’s mysql, you can use alter table like this:

ALTER TABLE t2 AUTO\_INCREMENT = /|value|/;

-Bill

Guillaume L. wrote:

> Hello everyone!
> 
> I have a table, “posts”. And I want to start the id from 1000. Is that  
> possible?  
> Do I need a migration?
> 
> Thank your for your help!

–  
“She was attempting to bicycle kick me when she raised her butt up and  
farted on me your honor.”  
“I have a list of all the dvd’s she had tooken…”  
“I called him because I was mad that he was spreadin my famly business  
round the trailer court…”  
“She said she had no money for rent but she was makin money strippin”  
“…they just completely at the point being turmoiled my life.”  
“…when the motor blowed up 2 months ago.”  
“I basically furnitured the whole house.”  
“I started the conversate on MySpace.”  
“I axed her what a lace from wig was and she axed me to come in for a  
consertation…”  
“He is the emotionalist man I eva seen…”  
“…it literally ranned over my car. I mean, it may be a 2002 DaeWoo,  
but it’s ma ride.”  
“…and here is a picture of your private parts.  
That’s when he stoled my phone.”

- Anonymous Quotes from Daytime Judge Shows

---

<div class="post-metadata">

**Author:** ![loader](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/5daacb/32.png) [@loader](https://www.ruby-forum.com/u/loader)\
**Post date:** [March 7, 2009, 1:01am UTC](https://www.ruby-forum.com/t/change-the-start-of-auto-increment/162220/3 "2009-03-07T01:01:49Z")

</div>

Yes I know but with rails we never change the Db manually right?? We use  
migrations?

---

<div class="post-metadata">

**Author:** ![loader](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/5daacb/32.png) [@loader](https://www.ruby-forum.com/u/loader)\
**Post date:** [March 7, 2009, 1:34am UTC](https://www.ruby-forum.com/t/change-the-start-of-auto-increment/162220/4 "2009-03-07T01:34:07Z")

</div>

Uhh, I wouldn’t say never. If you want to do it with a migration you  
will just have to execute the sql from the migration. Afaik, there is no  
special way to do this in a migration.

[http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/DatabaseStatements.html#M001887](http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/DatabaseStatements.html#M001887)

-Bill

Guillaume L. wrote:

> Yes I know but with rails we never change the Db manually right?? We use  
> migrations?

–  
“She was attempting to bicycle kick me when she raised her butt up and  
farted on me your honor.”  
“I have a list of all the dvd’s she had tooken…”  
“I called him because I was mad that he was spreadin my famly business  
round the trailer court…”  
“She said she had no money for rent but she was makin money strippin”  
“…they just completely at the point being turmoiled my life.”  
“…when the motor blowed up 2 months ago.”  
“I basically furnitured the whole house.”  
“I started the conversate on MySpace.”  
“I axed her what a lace from wig was and she axed me to come in for a  
consertation…”  
“He is the emotionalist man I eva seen…”  
“…it literally ranned over my car. I mean, it may be a 2002 DaeWoo,  
but it’s ma ride.”  
“…and here is a picture of your private parts.  
That’s when he stoled my phone.”

- Anonymous Quotes from Daytime Judge Shows
