Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change primary key values [duplicate]

Okay, so I'm not sure if this is possible but I need to change the primary key values in one table to match the FK values in another table.

What had happened is I created one table - POS_Transactions (FK REGISTER) - and imported its values, and then I created another table - Registers (pk REGISTERS_KEY) - and imported its values. But when I was importing the values for Registers, I came across some issues and had to clear the table and try it again multiple times (which is why the numbers go from 15-22, it just automatically updated that way) but I need them to say 1-8 so that it still connects to POS_Transactions.

Is there any way that I can change that?? And if so how do I do that? Sorry if that sounds stupid but I'm still new to SQL and I'm kind of stuck on what to do.

enter image description here

enter image description here

like image 574
hts95 Avatar asked Oct 15 '25 07:10

hts95


1 Answers

Do a Truncate table and try again.

You need to reset the Identity column.

like image 184
alexherm Avatar answered Oct 16 '25 19:10

alexherm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!