如果表B cols count等于tabl A,则从表B插入表A?

时间:2013-01-17 06:25:52

标签: sql tsql

我的表A有10列,表B只有3列。我希望将表B数据插入表A,其余7个字段为空。

我该怎么做?

3 个答案:

答案 0 :(得分:1)

如果您的表格列具有默认值,则必须使用: -

insert into tableA select col1,col2,col3,'','','','','','','' from tableB;

用于在剩余的7列中插入空值。

答案 1 :(得分:0)

使用

insert into table A(coulmn1,column2,coulmn3)  select * from B;

答案 2 :(得分:0)

Insert into tableA(col1, col2, col3) select col1, col2, col3 from tableB 
where col1=condition;

在oracle中测试

相关问题