开发者

sql: how to copy from one table into another table

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜