
- 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
What happens when I insert the value ‘NULL’ in an AUTO_INCREMENT MySQL column?
When we insert NULL value to AUTO_INCREMENT column, MySQL will return sequence number.
Example
mysql> Create table employee(id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, Name Varchar(10)); Query OK, 0 rows affected (0.16 sec) mysql> Insert into employee(id, Name) values(NULL, 'Gaurav'); Query OK, 1 row affected (0.07 sec) mysql> Select * from employee; +----+---------+ | id | Name | +----+---------+ | 1 | Gaurav | +----+---------+ 1 row in set (0.00 sec)
- Related Articles
- Passing NULL to MySQL for auto increment?
- Insert NULL value into INT column in MySQL?
- MySQL query to set my auto increment column ( id ) to zero or reset the value of auto increment field?
- Changing the current count of an Auto Increment value in MySQL?
- Insert default into not null column if value is null in MySQL?
- How do I insert a NULL value in MySQL?
- What role data type plays when I insert an empty string into a MySQL column which is declared as NOT NULL?
- How can I set my auto-increment value to begin from 1 in MySQL?
- How can I insert a value in a column at the place of NULL using MySQL COALESCE() function?
- What happens when a negative value is inserted to UNSIGNED column in MySQL?
- How to set initial value and auto increment in MySQL?
- How to handle fragmentation of auto increment ID column in MySQL?
- How to auto-increment value of tables to lower value in MySQL?
- What if I forgot to set Auto Increment? Can I set it later in MySQL?
- Change the Auto Increment counter in MySQL?

Advertisements