J
J
James_Obry2021-07-01 18:30:44
SQLite
James_Obry, 2021-07-01 18:30:44

How to change rowid of all other records in SQlite3 database after deleting one record?

I have a lot of records in the database, sometimes I delete one of them and all other records do not change their rowid.
Question: How, after deleting a record, to update the rowid of all the others so that they go in order?
I'm using the latest version of the Python programming language, and the SQlite3 database.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ronald McDonald, 2021-07-01
@Zoominger

It's not entirely clear why you would want to do this. PRIMARY KEY can not be changed like this, out of the blue, this is bad practice.
It is better to create a separate variable for this, some kind of record_id, but here the performance issue already arises - after each deletion, it is not very good to rewrite the entire table.
In short, the answer is: the problem does not have a correct solution, fix the application architecture.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question