简体   繁体   English

列大小不同时,将数据从一个表复制到另一个表

[英]Copy data from one table to another when column sizes are different

I have two tables t1 (old) with 4 columns and t2 (new table) with 6 columns. 我有两个具有4列的表t1(旧)和具有6列的t2(新表)。

I want to copy the data from t1 to t2 with date and 'ÝES' as default values in T2 as these values are not available in T1. 我想将数据从t1复制到t2并将日期和“ ES”作为T2中的默认值,因为这些值在T1中不可用。

  • T1 - 4 columns (c1, c2, c3, c4) T1-4列(c1,c2,c3,c4)
  • T2 - 6 columns (c1, c2, c3, c4, getdate(), 'ÝES') like I need T2-像我需要的6列(c1,c2,c3,c4,g​​etdate(),'ÝES')

Please help me with this. 请帮我解决一下这个。

这应该得到期望的结果:

insert into T2 (c1,c2,c3,c4,c5,c6) select c1,c2,c3,c4,sysdate, 'ÝES' from T1;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM