如果您未在insert语句中指定列列表,则可以使用以下语法-
insert into yourTableName values(NULL,yourValue,NULL,NULL,.....N);
让我们首先创建一个表-
mysql> create table DemoTable1513 -> ( -> StudentId int, -> StudentName varchar(20) , -> StudentAge int, -> StudentCountryName varchar(20) -> );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable1513 values(NULL,'Chris Brown',NULL,NULL); mysql> insert into DemoTable1513 values(101,NULL,NULL,NULL); mysql> insert into DemoTable1513 values(NULL,NULL,23,NULL); mysql> insert into DemoTable1513 values(NULL,NULL,NULL,'US');
使用select语句显示表中的所有记录-
mysql> select * from DemoTable1513;
这将产生以下输出-
+-----------+-------------+------------+--------------------+ | StudentId | StudentName | StudentAge | StudentCountryName | +-----------+-------------+------------+--------------------+ | NULL | Chris Brown | NULL | NULL | | 101 | NULL | NULL | NULL | | NULL | NULL | 23 | NULL | | NULL | NULL | NULL | US | +-----------+-------------+------------+--------------------+ 4 rows in set (0.00 sec)