CreatetableStudent(RollNOINT,NameVarchar(20),ClassVarchar(15));QueryOK,0rowsaffected(0.17sec) Now, we can run INSERTINTO statement without giving column names and values ​​as shown below -mysql>InsertintoStudent()"> What does MySQL return when running an INSERT INTO statement without giving a column name and value?-Mysql Tutorial-php.cn

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
836 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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!