Reputation: 34183
I'm trying to inspect my mysql database information_schema to find out the attributes of the columns. I can't find where the details as to which columns are auto_increment. Does anyone know where I can find this info in the information_schema DB?
Upvotes: 9
Views: 5098
Reputation: 1683
You could 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 | |
+----------+--------------+------+-----+---------+----------------+
Upvotes: 7
Reputation: 2109
see the EXTRA column in the COLUMNS table:
select * from COLUMNS where TABLE_SCHEMA='yourschema' and TABLE_NAME='yourtable' and EXTRA like '%auto_increment%'
Upvotes: 15