java - Refreshing PrimaryID to start from one after a deleted Row -
im programming programme in java , have database in jtable ones below. wanted know if possible refresh primaryid location 1 on gui interface form 1 when row deleted? illustration below loactionid deleted london , added 1 time again id 4. possible?
im using sql in java
to reply question, yes possible.
there no reason though, , highly recommend don't this.
the reason cosmetic ones - database doesn't care if records sequential, relate 1 consistently. there's no need "correct" values database's sake.
if utilize these id's kind of numbering on ui (cosmetic reason):
do not utilize identity this. separate visual row number, order or else internal database key.
if want this,
google "reseeding or resetting auto increment primary id's" sql product.
be aware solutions if reset identity seed below values have in table, violate indentity column's uniqueness constraint values start overlap
thanks andriy mentioning blindly pasting mysql solution :)
some examples:
alter table table_name alter column auto_increment_column_name restart 8 java db
dbcc checkident (mytable, reseed, 0)
altering sequence
java sql
No comments:
Post a Comment