How does one reformat an SQLite database so that the rowIds equal the placement on the table and when a row is deleted lower rows move up

StackOverflow https://stackoverflow.com/questions/9287814

Вопрос

I have recently come across a point where I need a database to do the above. I have looked online and have not found something that solves the problem and I understood. Another way to phrase the above question is "how could I make the rows always in integer order moving to replace voids filled by deleted rows?" Any help would be greatly appreciated.

Это было полезно?

Решение

One gets a greater understanding of what SQL is and how to use it within a given implementation to avoid considering questions and approaches that are incorrect and likely to lead to error-ridden, excessive, invalid, unmaintainable, results.
You don't change the primary key. You add an order column or use rownum(oracle) or something like that. Leave the rowids / primary key alone.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top