有没有一种方法可以在MySQL的INSERT语句中命名列?
是的,我们可以在插入语句中命名列。让我们首先创建一个表-
mysql> create table DemoTable674(StudentId int,
StudentFirstName varchar(100),
StudentLastName varchar(100)
);
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable674 set StudentId=10,StudentFirstName='John',StudentLastName='Smith';mysql> insert into DemoTable674 set StudentId=11,StudentFirstName='Carol',StudentLastName='Taylor';
mysql> insert into DemoTable674 set StudentId=12,StudentFirstName='David',StudentLastName='Miller';
mysql> insert into DemoTable674 set StudentId=13,StudentFirstName='Chris',StudentLastName='Brown';
使用select语句显示表中的所有记录-
mysql> select *from DemoTable674;
这将产生以下输出-
+-----------+------------------+-----------------+| StudentId | StudentFirstName | StudentLastName |
+-----------+------------------+-----------------+
| 10 | John | Smith |
| 11 | Carol | Taylor |
| 12 | David | Miller |
| 13 | Chris | Brown |
+-----------+------------------+-----------------+
4 rows in set (0.00 sec)
以上是 有没有一种方法可以在MySQL的INSERT语句中命名列? 的全部内容, 来源链接: utcz.com/z/316367.html