INSERT SELECT statement in Oracle 11G(Oracle 11G 中的 INSERT SELECT 语句)
问题描述
我正在尝试在 Oracle 11g 中运行一个非常简单的 sql 语句.
I'm trying to run a very simple sql statement in Oracle 11g.
insert into table1 (col1, col2) values (select t1.col1, t2.col2 from oldtable1 t1, oldtable2 t2);
非常简单的查询.笛卡尔将旧表 1 连接到旧表 2,将结果值放入表 1.
Very simple query. Cartesian join old table 1 to old table 2, put the resulting values into table 1.
我自己运行了子查询,它运行良好.
I've run the subquery by itself, and it works perfectly.
select t1.col1, t2.col2 from oldtable1 t1, oldtable2 t2
当我尝试运行完整语句时,出现以下错误:
When I try to run the full statement, I get the following error:
SQL Error: ORA-00936: missing expression
00936. 00000 - "missing expression"
我也无法让它在 MySql 中工作.我的陈述有问题,但我不确定是什么.
I can't get it to work in MySql either. Something is wrong with my statement, but I'm not sure what it is.
推荐答案
您的查询应该是:
insert into table1 (col1, col2)
select t1.col1, t2.col2
from oldtable1 t1, oldtable2 t2
即没有 VALUES 部分.
这篇关于Oracle 11G 中的 INSERT SELECT 语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Oracle 11G 中的 INSERT SELECT 语句
基础教程推荐
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 无法解决整理冲突 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
