0

I have an existing database with a key called myfile_id (int) . The code that I am working with wants it to be between 10,000 and 65,000 and there are already random entries in the database that i can't change (so there are random values between 1 and 65,000 already that I can't drop/change).

I want to set a constraint for the key to be non-Null, unique and for the keys to be auto-incrementing from 10,000 (but skip an existing value that comes in). How do I do this in Mysql?

Illusionist
  • 5,204
  • 11
  • 46
  • 76
  • 1
    Add a table which holds available values, take a value from it and delete used value, perform this in serialized transaction under locking. – Akina Jun 17 '20 at 18:46
  • Thanks, is there a way to write a trigger to generate a table within a range of values where a value is not already used? – Illusionist Jun 17 '20 at 19:33
  • 1
    *write a trigger to generate a table within a range of values where a value is not already used* Why trigger? this is a one-time task... – Akina Jun 17 '20 at 19:55
  • Thanks, i suppose it does . – Illusionist Jun 17 '20 at 21:34

0 Answers0