INSERT WITH SELECT (CAN’T SEEM TO FIND EXPLANATION)

pts.
Tags:
SQL
Can someone please explain the INSERT syntax that is in the Oracle Database 10g SQL class. I can't seem to find anyone who knows. An example of the statement that I don't understand is: INSERT INTO (SELECT last_name, salary FROM EMPLOYEES WHERE department_id = 50) VALUES (... What is the SELECT statement in the INSERT clause of the INSERT statement doing? Thanks for any help anyone can give me. Linda

Answer Wiki

Thanks. We'll let you know when a new response is added.

The SELECT statement is defining the column order for the VALUES and the TABLE to use. It has the same effect as INSERT INTO employees (last_name,salary) VALUES …
The WHERE clause does not have any effect on column selection nor does it provide a default value for department_id.
Tested on: OracleXE for Windows 10gR2
Regards
Peter Wilkinson
Senior Oracle DBA
Mercury International Ltd

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following