Home > Database > Mysql Tutorial > body text

What does MySQL return when running an INSERT INTO statement without giving a column name and value?

王林
Release: 2023-09-21 21:09:03
forward
899 people have browsed it

在没有给出列名和值的情况下运行 INSERT INTO 语句时 MySQL 返回什么?

When we run the INSERT INTO statement without giving the column name and value, MySQL stores NULL as the value of the table column. Consider the example given below, in which we have created a table "Student" using the following query -

mysql> Create table Student(RollNO INT, Name Varchar(20), Class Varchar(15));
Query OK, 0 rows affected (0.17 sec)
Copy after login

Now we can run the INSERT INTO statement without giving the column names and values ​​as shown below-

mysql> Insert into Student() Values();
Query OK, 1 row affected (0.02 sec)
Copy after login

From the query below we can see that MySQL stores NULL as the value of the column.

mysql> Select * from Student;

+--------+------+-------+
| RollNO | Name | Class |
+--------+------+-------+
| NULL   | NULL | NULL  |
+--------+------+-------+

1 row in set (0.00 sec)
Copy after login

Every time we run an INSERT INTO statement without giving both a column name and a value, MySQL stores NULL as the value of the table's column.

mysql> Insert into Student() Values();
Query OK, 1 row affected (0.03 sec)

mysql> Select * from Student;

+--------+------+-------+
| RollNO | Name | Class |
+--------+------+-------+
| NULL   | NULL | NULL  |
| NULL   | NULL | NULL  |
+--------+------+-------+

2 rows in set (0.00 sec)
Copy after login

The above is the detailed content of What does MySQL return when running an INSERT INTO statement without giving a column name and value?. 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