Jump to content

[SOLVED] resetting a primary key?


Dragen

Recommended Posts

Hi,

Is it possible to reset a primary key within a database?

I've been using my database to test things and I have a primary key which is now in its thousands when I add things to it, although there is nothing on it at the moment.

Can I reset it so that it starts at 1 again?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/46798-solved-resetting-a-primary-key/
Share on other sites

yeah thanks. That's good if you've got stuff on the table that you want to keep.

I found that if you use truncate it resets the values of auto primary keys (although deleting everything else on the table), which is fine for what I need as when I reset the primary key I want everything else deleted as well:

mysql_query("TRUNCATE table TABLE_NAME");

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.