Re: [sqlite] Resetting autoincrement

2018-04-14 Thread R Smith

On 2018/04/14 12:16 AM, Mike Clark wrote:

I found this on Stackoverflow:

DELETE FROM your_table;DELETE FROM sqlite_sequence WHERE name =
'your_table';


But when I try to run it I get "table not found". Has this been superseded?


It has not been superseded, it has never even been the defacto method. 
It's a bit of a fudge to reset the Autoincrement value since the SQLite 
AUTOINCREMENT constraint on an INTEGER PRIMARY KEY will use the 
mentioned "sqlite_sequence" table to decide the next key value.


My guess is, if this did not work for you, that you have NOT used the 
AUTOINCREMENT specifier when creating your table, and so your keys will 
not recall the last key value - which is bad DB practice, but may be 
fine for your use case.


This also means you may still have incrementing integer primary keys, 
but they are not kept in said table - which in turn means the primary 
key value, once deleted from your data table, may at some point be used 
again, whereas if you specifically set the integer primary key to be of 
the "AUTOINCREMENT" variety,  a value can never be used again, even 
after it was deleted.


If I am right, you can just continue, after clearing the table, and the 
incrementing should start from 1 again. If this is not the case, post 
again but include your schema to remove the guesswork.


Cheers!
Ryan




___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Resetting autoincrement

2018-04-14 Thread Simon Slavin

> On 13 Apr 2018, at 11:16 pm, Mike Clark  wrote:
> 
> DELETE FROM your_table;DELETE FROM sqlite_sequence WHERE name =
> 'your_table';
> 
> 
> But when I try to run it I get "table not found". Has this been superseded?

No. What is the primary key on that table ?  If you declared is in the CREATE 
command what did you make it ?
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] what sqlite3_memory_used mean??

2018-04-14 Thread Richard Hipp
On 4/13/18, king3306 <1809860...@qq.com> wrote:
> HI
>
> I use sqlite3 in embedded arm
>
> my memory is very small  about 4M
>
> so i want to use MEMSYS5  to limit memory use
>
> i define DSQLITE_ENABLE_MEMSYS5   1  in sqlite3.c
>
> compile it
>
> in my code start  i use
>
>   
> sqlite3_config(SQLITE_CONFIG_HEAP,malloc(2*1024*1024),2*1024*1024);

sqlite3_config() is a varargs function.  SQLITE_CONFIG_HELP wants
three additional arguments, but you only gave it two.  It might better
if you gave it the third argument.  I suggest a value of 64.

Also, make sure sqlite3_config() returns SQLITE_OK.

>   sqlite3_config(SQLITE_CONFIG_PAGECACHE,malloc(4*1024),4*1024);

Again, you omitted the final argument.  And even then, it seems kind
of silly to configure a page cache that only holds one page.

Start by omitting the SQLITE_CONFIG_PAGECACHE call.  That will cause
SQLite to you the 2MiB of HEAP that you configured for the cache it
needs.

>
> before open database
>
> my purpose  is to limit memory usage < 2M + 4K
>
> but  i found sqlite3_memory_used=29126656
>
> is use 27M??  i can"t understand why
>
> what sqlite3_memory_used mean ?
>
>
>
>
>
> --
> Sent from: http://sqlite.1065341.n5.nabble.com/
> ___
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] what sqlite3_memory_used mean ?

2018-04-14 Thread king3306
HI 

I use sqlite3 on embedded arm 

my memory is very small  free memory about 6M 

so i want to use MEMSYS5  to limit memory use 

i define DSQLITE_ENABLE_MEMSYS5=1  in sqlite3.c 

compile it 

in my code start  i use 

   
sqlite3_config(SQLITE_CONFIG_HEAP,malloc(2*1024*1024),2*1024*1024); 
   
sqlite3_config(SQLITE_CONFIG_PAGECACHE,malloc(4*1024),4*1024); 

before open database 

my purpose  is to limit memory usage < 2M + 4K 

but  i found sqlite3_memory_used=29126656 

is use 27M??  i can"t understand why 

what sqlite3_memory_used mean ? 

if i want to limit memory about 4M ? what i should config the sqlite3?



--
Sent from: http://sqlite.1065341.n5.nabble.com/
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] what sqlite3_memory_used mean ?

2018-04-14 Thread king3306
HI 

I use sqlite3 in embedded arm 

my memory is very small  about 4M 

so i want to use MEMSYS5  to limit memory use 

i define DSQLITE_ENABLE_MEMSYS5   1  in sqlite3.c 

compile it 

in my code start  i use 

   
sqlite3_config(SQLITE_CONFIG_HEAP,malloc(2*1024*1024),2*1024*1024); 
   
sqlite3_config(SQLITE_CONFIG_PAGECACHE,malloc(4*1024),4*1024); 

before open database 

my purpose  is to limit memory usage < 2M + 4K 

but  i found sqlite3_memory_used=29126656 

is use 27M??  i can"t understand why 

what sqlite3_memory_used mean ? 



--
Sent from: http://sqlite.1065341.n5.nabble.com/
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] what sqlite3_memory_used mean??

2018-04-14 Thread king3306
HI

I use sqlite3 in embedded arm 

my memory is very small  about 4M

so i want to use MEMSYS5  to limit memory use

i define DSQLITE_ENABLE_MEMSYS5   1  in sqlite3.c

compile it

in my code start  i use 


sqlite3_config(SQLITE_CONFIG_HEAP,malloc(2*1024*1024),2*1024*1024);
sqlite3_config(SQLITE_CONFIG_PAGECACHE,malloc(4*1024),4*1024);

before open database

my purpose  is to limit memory usage < 2M + 4K

but  i found sqlite3_memory_used=29126656

is use 27M??  i can"t understand why 

what sqlite3_memory_used mean ?





--
Sent from: http://sqlite.1065341.n5.nabble.com/
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Resetting autoincrement

2018-04-14 Thread Mike Clark
I found this on Stackoverflow:

DELETE FROM your_table;DELETE FROM sqlite_sequence WHERE name =
'your_table';


But when I try to run it I get "table not found". Has this been superseded?
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users