Django model instances primary keys do not reset to 1 after all instances are deleted

I wouldn’t call it an issue. This is default behaviour for many database systems. Basically, the auto-increment counter for a table is persistent, and deleting entries does not affect the counter. The actual value of the primary key does not affect performance or anything, it only has aesthetic value (if you ever reach the 2 … Read more

SQL-script: How to write ALTER statements to set Primary key on an existing table?

drop constraint and recreate it alter table Persion drop CONSTRAINT <constraint_name> alter table Persion add primary key (persionId,Pname,PMID) edit: you can find the constraint name by using the query below: select OBJECT_NAME(OBJECT_ID) AS NameofConstraint FROM sys.objects where OBJECT_NAME(parent_object_id)=’Persion’ and type_desc LIKE ‘%CONSTRAINT’

tech