0

How do I clear data from a column and then set the first value as 1 with auto increment? I do not want to delete the column, merely to reset it.

edit: This is for my mysql database

user701510
  • 5,563
  • 17
  • 61
  • 86

3 Answers3

1

Do not do it.
Auto-increment column is untouchable by design.

If you reset it, you will break your application.

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
1
  1. TRUNCATE TABLE tbl -- will erase everything from the table
  2. ALTER TABLE tbl AUTO_INCREMENT = 1
zerkms
  • 249,484
  • 69
  • 436
  • 539
-1

UPDATE TABLE SET col=0;

UPDATE Table AS T1 SET T1.col=1+ (SELECT MAX(T2.COL) FROM TABLE AS T2)

That should do it.

Steven Feldman
  • 833
  • 1
  • 15
  • 28