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

july_12 · 2014年05月28日 · 最后由 geekontheway 回复于 2014年05月28日 · 1958 次阅读

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

需要 登录 后方可回复, 如果你还没有账号请 注册新账号