开发者

sql: how to copy from one table into another table

开发者 https://www.devze.com 2023-01-18 22:39 出处:网络
table A\'s structure is a subset of table B, that means the ta开发者_StackOverflow中文版ble A\'s all the columns are the first columns of table B, but table B has more columns than table A. My questio

table A's structure is a subset of table B, that means the ta开发者_StackOverflow中文版ble A's all the columns are the first columns of table B, but table B has more columns than table A. My question, what's the SQL statment to copy all the rows from table A to table B(the missing columns in table B will be kept empty).


Use:

INSERT INTO TABLE_B
SELECT col1,
       col2,
       col3,
       NULL
  FROM TABLE_A

Use NULL as the placeholder for however many columns you can't populate from TABLE_A, assuming TABLE_B columns allow NULL values.

0

精彩评论

暂无评论...
验证码 换一张
取 消