Auto-increment is not resetting in MySQL

后端 未结 8 1477
花落未央
花落未央 2020-12-03 17:53

I am trying to set up a script to generate a particular set of test data into my database, at the beginning of which I want to clear the tables concerned without dropping co

8条回答
  •  醉话见心
    2020-12-03 18:20

    Can you not drop the relevant, auto increment column and recreate it? Example follows:

    ;;assuming your column is called id and your table is tbl
    ALTER TABLE tbl DROP COLUMN id;
    ALTER TABLE tbl ADD COLUMN id BIGINT UNSIGNED DEFAULT 1 PRIMARY KEY FIRST;
    

    This should work, but I don't use MySQL, just going off the docs. If you need further help, leave a comment and I'll do my best to help out.

提交回复
热议问题