- Related Questions & Answers
AUTO INCREMENT Field. Auto-increment allows a unique number to be generated automatically when a new record is inserted into a table. Often this is the primary key field that we would like to be created automatically every time a new record is inserted.
- Selected Reading
While creating a table, in certain scenarios, we need values to column such as ID, to be generated/incremented automatically. Various databases support this feature in different ways.
In MySQL database you can declare a column auto increment using the following syntax.
MySQL query to create a table with auto-incremented column.
Android Room Primary Key
Example
Unique Key
Following JDBC program establishes a connection with MYSQL database and creates a query with an auto-incremented column.
Output
Verification
The DESCRIBE command in MYSQL gives the description of a table, you can verify the creation of the table with auto-incremented column using it, as shown below −