
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How to find if a column is auto_increment in MySQL?
To find if a column is auto_increment in MySQL, you can use the following syntax −
select COLUMN_NAME from information_schema.columns where TABLE_SCHEMA='yourDatabaseName' and TABLE_NAME='yourTableName' and EXTRA like '%auto_increment%';
Let us first create a table. Here, ClientId is set AUTO_INCREMENT −
mysql> create table autoIncrementTableDemo -> ( -> ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> ClientName varchar(20), -> ClientAge int, -> ClientAddress varchar(100), -> ClientCountryName varchar(100) -> ); Query OK, 0 rows affected (0.61 sec)
Now, let us find whether any of the column is auto_increment −
mysql> select COLUMN_NAME from information_schema.columns where TABLE_SCHEMA='test' and TABLE_NAME='autoIncrementTableDemo' and EXTRA like '%auto_increment%';
Following is the output that gives the column i.e. auto_increment −
+-------------+ | COLUMN_NAME | +-------------+ | ClientId | +-------------+ 1 row in set (0.00 sec)
- Related Articles
- How to handle fragmentation of auto increment ID column in MySQL?
- How to add auto-increment to column in MySQL database using PhpMyAdmin?
- How to create a table with auto-increment column in MySQL using JDBC?
- MySQL query to set my auto increment column ( id ) to zero or reset the value of auto increment field?
- How to change auto increment number in MySQL?
- Set MySQL int column to auto increment by 1 beginning at 10000?
- How to get the next auto-increment id in MySQL?
- How to set initial value and auto increment in MySQL?
- How to make MySQL table primary key auto increment?
- Passing NULL to MySQL for auto increment?
- How to change auto increment number in the beginning in MySQL?
- Change the Auto Increment counter in MySQL?
- How to set auto-increment to an existing column in a table using JDBC API?
- Add a column to a MySQL table which is the result of concatenation of text and value from another auto increment column?
- How to auto-increment value of tables to lower value in MySQL?

Advertisements