First time here? Check out the FAQ!
asked 2012-07-20 14:57:40 +0200
Anonymous
Say I have a table with 4 rows and the id column (primary key) has the values 1,2,3,4.
When I delete row 2, is it possible in Base to update the primary keys so that the remaining 3 rows get the id values of 1,2,3 and not 1,3,4?
Hi Anon, @DonLow,
In most databases, primary key values are not shuffled around upon deletion of rows. There are a couple of reasons for doing this:
What's the use case in which you'd want to renumber all of the primary keys?
If you really need to have that kind of id in your table, instead of changing all of the primary keys, why not just put a new column "order_id" into your table. Whenever you delete a row from the table, iterate over the remaining rows (in ascending order by primary key) and set order_id to the appropriate value.
LibreOffice is made available by volunteers around the globe, backed by a charitable Foundation. Please support our efforts: Your donation helps us to deliver a better product!
Asked: 2012-07-20 14:57:40 +0200
Seen: 112 times
Last updated: Mar 06
How to copy Biblio from Windows to Ubuntu?
How to paste tab delimited data into base table
How do I create a field in a table with that must be Unique?
Base crashes when using "Save As"
3.5.5 Mail merge creates document with fields instead of editable text [closed]
How do you use the ROWNUM function (or similar) in LibreOffice Base query?
Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.
I hope someone answers this. I'd like to know also.
DonLow ( 2012-08-14 04:00:55 +0200 )edit