#1 2016-10-30 10:45:52

xchinjo
Member
From: Thailand
Registered: 2016-04-29
Posts: 41
Website

how to reset table id ?

how to reset table id  to 0 or any number?


Jongruk Aripoo

Offline

#2 2016-10-30 17:54:48

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: how to reset table id ?

There is no record with Id=0 by design.

Offline

#3 2016-10-30 23:29:10

xchinjo
Member
From: Thailand
Registered: 2016-04-29
Posts: 41
Website

Re: how to reset table id ?

i'm sorry, i mean reset to 1


Jongruk Aripoo

Offline

#4 2016-10-31 07:41:31

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: how to reset table id ?

I don't understand what you mean...
Do you mean change the record ID to another value?

In this case, there is no way of doing it directly from the ORM, but by creating new records with the new ID and copied fields values, then delete the old records.
You may do it using raw SQL, anyway - but ensure you flush the cache.

Offline

#5 2016-10-31 09:52:42

xchinjo
Member
From: Thailand
Registered: 2016-04-29
Posts: 41
Website

Re: how to reset table id ?

i mean like this post
http://synopse.info/forum/viewtopic.php?id=1664

after delete all data  of table the ID already continued value. i want to reset id to start from number 1 when the table is empty
,How to flush the cache?

Last edited by xchinjo (2016-10-31 09:56:05)


Jongruk Aripoo

Offline

#6 2016-10-31 11:44:17

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: how to reset table id ?

For a SQlite3 table, it is a SQLite3 feature.
See http://stackoverflow.com/a/3443682/458259

Offline

#7 2016-10-31 13:03:49

xchinjo
Member
From: Thailand
Registered: 2016-04-29
Posts: 41
Website

Re: how to reset table id ?

Thank you. Ab


Jongruk Aripoo

Offline

#8 2016-10-31 13:51:18

jbroussia
Member
From: France
Registered: 2011-04-09
Posts: 74

Re: how to reset table id ?

Doesn't VACUUM do this in SQLite ?

Offline

Board footer

Powered by FluxBB