Solved

Insert table rows from SQL query

Posted on 2007-11-14
4
2,339 Views
Last Modified: 2013-12-19
How do I write Oracle SQL expression (using TOAD) that inserts rows into a table from a select statement, ie "Insert into table(field 1, field 2, field 3, etc) values(select field1, field2, field3 from tables where conditions)"?

Thank you.
0
Comment
Question by:pelican45
  • 2
4 Comments
 
LVL 3

Expert Comment

by:davisnw
Comment Utility
insert into destinationTable (field1, field2, field3) SELECT field1,field2, field3 from sourcetable where ....
0
 
LVL 3

Accepted Solution

by:
davisnw earned 250 total points
Comment Utility
(Basically, when you do an insert based on a select, you simply omit the VALUES key word)
0
 
LVL 28

Assisted Solution

by:Naveen Kumar
Naveen Kumar earned 250 total points
Comment Utility
even we can do it like this ( in this case we should ensure that our select list has that many number of columns which are required for the destination table ). Ofcourse, the data types of the select list columns and data types
should match as well which is normal for any insert command.

insert into destinationTable SELECT field1,field2, field3 from sourcetable where ....

Thanks

0
 

Author Closing Comment

by:pelican45
Comment Utility
Thank you both
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now