INSERT SELECT语句在Oracle 11G中
我试图在Oracle 11g中运行一个非常简单的sql语句。
insert into table1 (col1, col2) values (select t1.col1, t2.col2 from oldtable1 t1, oldtable2 t2);
非常简单的查询。 笛卡尔联接旧表1到旧表2,将结果值放入表1中。
我已经自己运行子查询,它完美的工作。
select t1.col1, t2.col2 from oldtable1 t1, oldtable2 t2
当我尝试运行完整的语句时,出现以下错误:
SQL Error: ORA-00936: missing expression
00936. 00000 - "missing expression"
我无法让它在MySql中工作。 我的说法有些不对,但我不确定它是什么。
您的查询应该是:
insert into table1 (col1, col2)
select t1.col1, t2.col2
from oldtable1 t1, oldtable2 t2
即没有VALUES部分。
摆脱values关键字和parens。 你可以在这里看到一个例子。
使用'select'作为源时,不需要'values'子句。
insert into table1 (col1, col2)
select t1.col1, t2.col2 from oldtable1 t1, oldtable2 t2;
链接地址: http://www.djcxy.com/p/94323.html
上一篇: INSERT SELECT statement in Oracle 11G
下一篇: How can I copy data from one column to another in the same table?
