

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Questions & Answers
- How to handle fragmentation of auto increment ID column in MySQL?
- How to create a table with auto-increment column in MySQL using JDBC?
- How to add auto-increment to column in MySQL database using PhpMyAdmin?
- How to change auto increment number in MySQL?
- MySQL query to set my auto increment column ( id ) to zero or reset the value of auto increment field?
- Passing NULL to MySQL for auto increment?
- Set MySQL int column to auto increment by 1 beginning at 10000?
- How to make MySQL table primary key auto increment?
- Change the Auto Increment counter in MySQL?
- How to get the next auto-increment id in MySQL?
- How to set initial value and auto increment in MySQL?
- How to change auto increment number in the beginning in MySQL?
- Set custom Auto Increment with ZEROFILL in MySQL
- Add a column to a MySQL table which is the result of concatenation of text and value from another auto increment column?
- How to set auto-increment to an existing column in a table using JDBC API?
Advertisements