将数据从一个 table 添加到另一个

Add data from one table into another

table1 看起来像:

col1   col2   col3
-------------------
foo    bar    baz
lorem  ipsum  dolor

table2 看起来像:

col1     col2   col3     col4   col5
-----------------------------------------
sitting  onthe  dock     ofthe  bay
heard    it     through  the    grapevine

我想将 table1 中的所有数据导入 table2:

col1     col2   col3     col4   col5
-----------------------------------------
sitting  onthe  dock     ofthe  bay
heard    it     through  the    grapevine
foo      bar    baz
lorem    ipsum  dolor

通常情况下,如果数据结构相同,我会在下面使用,但这在这里不起作用(显然)。

select * into table2 from table1

在这种情况下,正确的导入方式是什么?

您需要使用 Insert INTO

指定列
Insert Into table2 (col1,col2,col3)
Select col1,col2,col3
  From table1