当我们运行 insert into 语句而不给出列名和值时,mysql 会将 null 存储为表列的值。考虑下面给出的示例,其中我们使用以下查询创建了一个表“student” -
mysql> create table student(rollno int, name varchar(20), class varchar(15));query ok, 0 rows affected (0.17 sec)
现在,我们可以运行 insert into 语句,而无需给出列名称和值,如下所示 -
mysql> insert into student() values();query ok, 1 row affected (0.02 sec)
从下面的查询中我们可以看到mysql将null存储为列的值。
mysql> select * from student;+--------+------+-------+| rollno | name | class |+--------+------+-------+| null | null | null |+--------+------+-------+1 row in set (0.00 sec)
每次我们运行 insert into 语句而不同时给出列名和值时,mysql 都会将 null 存储为表的列的值。
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)
以上就是在没有给出列名和值的情况下运行 insert into 语句时 mysql 返回什么?的详细内容。