Home > Database > Mysql Tutorial > What happens when I insert the value 'NULL' into an AUTO_INCRMENT MySQL column?

What happens when I insert the value 'NULL' into an AUTO_INCRMENT MySQL column?

王林
Release: 2023-09-17 14:45:03
forward
874 people have browsed it

当我在 AUTO_INCRMENT MySQL 列中插入值“NULL”时会发生什么?

When we insert a NULL value into the AUTO_INCRMENT column, MySQL will return the 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)
Copy after login

The above is the detailed content of What happens when I insert the value 'NULL' into an AUTO_INCRMENT MySQL column?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template