Igor Tandetnik <itandetnik@...> writes:

> 
> Balasubramani Vivekkanandan <bvivekkanandan@...> wrote:
> >    I am very new database development and sqlite. I have a requirement
> > where I want to restrict the size of my integer primary key to 3 bytes.
> > In my database, entries will be added and removed very frequently. So If the
> > primary key limit of 3 bytes is reached, it should try to reuse the deleted
> > entries.
> 
> What purpose exactly is this, rather bizarre, requirement supposed to serve,
if you don't mind me asking?
> 
> > Is this possible with sqlite?
> 
> Not automatically. You can implement it in your application code.


sorry that I've to contradict but I believe(!) that it should be possible
this way:

1. create table using INTEGER PRIMARY KEY (without autoincrement)
2. create an extra table with an 1 column
3. INSERT a 0 (zero) in that extra table
4. create a TRIGGER that fires if the id reaches the max(id) + 1, checks the
Integer in the extra table and INSERTS integer + 1 in main table (REPLACE),
INSERTS the new id in extra table by REPLACING the old one (DELETE and INSERT)

just a few thopughts without having tested

greetings
oliver



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to