Home > Database > Mysql Tutorial > Why is my Oracle 11g 'INSERT SELECT' statement returning an ORA-00936 error?

Why is my Oracle 11g 'INSERT SELECT' statement returning an ORA-00936 error?

Susan Sarandon
Release: 2025-01-02 19:03:41
Original
594 people have browsed it

Why is my Oracle 11g

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);
Copy after login

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
Copy after login

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template