【问题标题】:SQL inserting data from tabl1 to tabl2SQL将数据从table1插入table2
【发布时间】:2015-05-07 10:25:25
【问题描述】:

我在 SQL 中有 2 个表

  • 表 1:col1、col2、col3、col4、col5、col6、col7
  • 表 2:col1、col2、col4、col5、col10(newcol)

col10 (newcol) 应该被赋予默认值 0

我需要将表1的数据复制到表2

【问题讨论】:

标签: sql


【解决方案1】:

这是一个使用选择的非常简单的插入。如果您只需要执行一次,您可以跳过查询并使用菜单选项导入数据,然后按照提示进行操作。否则:

INSERT INTO table2
(col1, col2, col4, col5, col10)
SELECT col1, col2, col4, col5, 0
FROM table1;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多