在MySQL中插入值时,可以跳过某一列的列名吗?
可以。让我们首先创建一张表 –
mysql> create table DemoTable
-> (
-> StudentName varchar(100),
-> StudentAge int
-> );
Query OK, 0 rows affected (0.72 sec)
使用插入命令向表中插入一些记录 –
mysql> insert into DemoTable(StudentAge) values(23);
Query OK, 1 row affected (0.22 sec)
mysql> insert into DemoTable(StudentName) values('John');
Query OK, 1 row affected (0.21 sec)
使用select语句从表中显示所有记录 –
mysql> select *from DemoTable;
这将产生以下输出。跳过的列值将插入NULL –
+-------------+------------+
| StudentName | StudentAge |
+-------------+------------+
| NULL | 23 |
| John | NULL |
+-------------+------------+
2 rows in set (0.00 sec)
阅读更多:MySQL 教程
极客教程