更新时间:2023-12-01 09:35:34
运行时:
insert into one
select * from two;
SQL引擎自动将其包含在隐含的列中.
The SQL engine automatically puts in the columns that are implied.
insert
,这是声明顺序的列列表.*
,这是声明顺序的列列表.insert
, this is the list of columns in declaration order.*
, this is the list of columns in declaration order.按名称没有列的匹配",只有每个表中的列的列表.
There is no "matching" of columns by names, only lists of columns in each table.
因此,查询实际上是:
insert into one(a, b)
select b from two;
在我看来这是一个错误.
That looks like an error to me.
故事的道德?编写您想要的代码.始终包括列列表,尤其是对于insert
语句.所以写:
Moral of the story? Write that code that you intend. Always include columns lists, particularly for insert
statements. So write:
insert into one(b)
select b from two;