Troubleshooting an "INSERT SELECT" Statement in Oracle 11G
Attempting to execute the following "INSERT SELECT" statement in Oracle 11G:
insert into table1 (col1, col2) values (select t1.col1, t2.col2 from oldtable1 t1, oldtable2 t2);
However, the statement is returning an ORA-00936 error: "missing expression."
Analysis and Resolution
Upon closer inspection, it becomes apparent that the statement is syntactically incorrect. Specifically, the "VALUES" keyword is unnecessary in an "INSERT SELECT" statement. The correct syntax is as follows:
insert into table1 (col1, col2) select t1.col1, t2.col2 from oldtable1 t1, oldtable2 t2
After removing the "VALUES" keyword, the statement should execute without error.
The above is the detailed content of Why is my Oracle 11g 'INSERT SELECT' statement returning an ORA-00936 error?. For more information, please follow other related articles on the PHP Chinese website!