How to reset the number of primary keys / max in kernel data?

I managed to delete all objects stored using Core Data (after this answer ).

The problem is that I noticed that the primary key is still counting up. Is there a way (without manually writing an SQL query) to reset the Z_MAX value for an object? Screenshot below to clarify what I mean.

The value in itself is not a problem, but I'm just worried that at some point in the future, the maximum number may be reached, and I do not want this to happen. My application synchronizes data with a web service and caches it using master data, so the potential primary key can increase by hundreds / thousands at a time. Removing the entire Sqlite DB is not an option, since I need to save some of the information for other objects.

I saw the reset 'method, but of course will the whole Sqlite DB be reset? How can I reset the primary key only for this set of objects? There is no relationship with other objects with the main key that I want to use reset.

Screen shot

+3
source share
4 answers

, - , .

? ? , , Int16, . 32- 2 147 483 647 . 64- 9,223,372,036,854,775,807.

, , , , , , .

, Core Data, . Core Data - Core Data . .

+8

64- . - , , .

, bugreport.apple.com, .

+8

sqlite faq:

, 9223372036854775807, .

9,223,372,036,854,775,807/(1024 ^ 4) = 8 388 608 tera-. , .:) http://www.sqlite.org/limits.html , .

sqlite3 :

sqlite> .schema zbookmark
CREATE TABLE ZBOOKMARK ( Z_PK INTEGER PRIMARY KEY, ...

"", sqlite . , , , ( ) .

reset, , -, z_- - . [ not, , , . ( , , ), .]

+2

, / Core Data , :

.

Of course, you will lose all your data, but if you are concerned about this small number, then this is normal, right?

Oh, and Core Data will definitely have primary key collisions.

+1
source

Source: https://habr.com/ru/post/1784839/


All Articles