Angle Tom
Angle Tom

Reputation: 1130

How to get all the tables with auto increment primary key in mysql?

There are huge tables in my mysql database, I want to get all the tables with auto increment columns and the columns' names. Could anyone teach me how to do that ?

Upvotes: 1

Views: 1531

Answers (1)

brass monkey
brass monkey

Reputation: 6771

I think you can get that information from the COLUMNS table in the INFORMATION_SCHEMA schema.

E.g.

select TABLE_NAME, COLUMN_NAME from COLUMNS where `COLUMN_KEY` = 'PRI' and EXTRA like '%auto_increment%'

Upvotes: 2

Related Questions