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()"/> 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()">
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)
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)
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)
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)
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!