How to find out if an auto_increment column is in mysql?

I am trying to check my mysql information_schema database to find out the attributes of the columns. I cannot find information about which columns are auto_increment. Does anyone know where I can find this information in the Information_schema DB?

+6
database mysql
source share
2 answers

see the EXTRA column in the COLUMNS table:

select * from COLUMNS where TABLE_SCHEMA='yourschema' and TABLE_NAME='yourtable' and EXTRA like '%auto_increment%' 
+11
source share

you can use

 mysql> DESCRIBE yourtable; 

Example:

 mysql> use my_database; mysql> describe users; +----------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------+--------------+------+-----+---------+----------------+ | user_id | int(11) | NO | PRI | NULL | auto_increment | | password | varchar(128) | NO | | NULL | | | email | varchar(128) | NO | | NULL | | +----------+--------------+------+-----+---------+----------------+ 
+4
source share

All Articles