From The Document Foundation Wiki
The primary key is autogenerated and the table contains data
Starting situation: non-continuous numbering
- Create the following numbering: the table contains 20 rows, for example, removing the last row, restart numbering at 15.
- Use the SQL command above, modifying the starting value to 15.
- Completely renumber (changing the existing keys): use the "copy table" wizard.
- Copy and paste the table or move it slightly with the mouse: the wizard will appear.
- Supply a new name for the table
- Choose the option Structure and Data, click on Next
- Select all the fields except the primary key
- Click on Create. LibreOffice will suggest creating a primary key: choose No
- The new table is created. Modify it by adding a primary key field, autogenerate the value, save.