?
Solved

Insert table rows from SQL query

Posted on 2007-11-14
4
Medium Priority
?
2,373 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Expert Comment

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

Accepted Solution

by:
davisnw earned 1000 total points
ID: 20286064
(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 1000 total points
ID: 20297855
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
ID: 31409274
Thank you both
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

764 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