1. Django + PostgreSQL: How to reset primary key?
http://stackoverflow.com/questions/544791/django-postgresql-how-to-reset-primary-key
這個是用於在清除表中資料後,資料的pk 不從1開始成長,將序列重新設定為1的方法。
In your app directory try this:
python manage.py help sqlsequencereset
o 🜎
python manage.py sqlsequencereset myapp1 myapp2 | psql
Edit: here's an example of the output from this command on one of my _id_seq"', coalesce(max("id "), 1), max("id") IS NOT null) FROM "project_row";
COMMIT;