Sami
Sami

Reputation: 8419

drop auto-increment fields

  1. If solution to the problem in title is possible, please guide. I have not found it anywhere.
  2. If it is possible (to drop auto-increment field without naming it at table, level please guide.
  3. I can read it from extra field of information_schema.columns and have its name, then it would easy to drop that column from a specific table. But i am seeking for a better solution.
  4. Is there any better/quick solution than my point#3

Question (If it is not already clear :)

Is there any query/function to drop all auto-increment columns from database? or at least is there a way to drop an auto-increment column from specific table without knowing the name of that column?

I am thinking this because there can be only 0 or 1 auto-increment column in a table, so mysql might have some built-in extended function to deal with that type of field

Upvotes: 0

Views: 229

Answers (2)

Barmar
Barmar

Reputation: 781004

While there's no built-in mechanism to do this, you could write a script that reads information_schema and generates all the necessary alter table commands.

Upvotes: 0

Maksym Polshcha
Maksym Polshcha

Reputation: 18358

There is no such builtin function. Your point #3 is a good option to do this in MySQL. you can also parse desc mytable output.

Upvotes: 1

Related Questions