数据库 how to set id from 1 begin after delete_all

july_12 · May 28, 2014 · Last by geekontheway replied at May 28, 2014 · 1952 hits

sometimes, we want to refresh the data of X table, we do that by "X.delete_all" method.

after that, when you create new a row data which its id is not from 1 begin instead of from

last record before I delete it, how can I operate so that I can get consequence what just I mention at title.

my guess is that this should be handled by the database not rails try ALTER TABLE table AUTO_INCREMENT = 1 or alternatively you can truncate your table

@leozwa Thx, you right, it work for me now!

use SQL truncate

You need to Sign in before reply, if you don't have an account, please Sign up first.