Hello,
I am currently using django and mysql in conjunction.
When db builds up, objects.all().delete() deletes the entire data and saves it again and again.
If you delete objects.all().delete(), the entire data will be deleted.
The ID(pk) numbers keep piling up, can you erase this value as well?
Delete 10 data with objects.all().delete() and enter the data again.
The id(pk) is re-entered from number 11, so I would like to ask if I can start the id value from number 1.
django mysql
The table is really temporary, so if you can fly it like that, you can do something called TRUNCATE
. https://stackoverflow.com/a/2989122
However, if id
goes up from 11
just because you don't like aesthetics, (I used to do that)... We recommend that you just change your preference and stick to all().delete()
. This is because the auto incremental replacement key is an index that should be used well when present. If there is a problem with data consistency later, it may be too late by then.
577 PHP ssh2_scp_send fails to send files as intended
890 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
610 Uncaught (inpromise) Error on Electron: An object could not be cloned
568 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.