How to insert data from one table to another table without insert command and cursors

Showing Answers 1 - 30 of 30 Answers

anubhaawadhiya

  • Feb 26th, 2007
 

1. if the two tables have same columns
select * from <table1> into <table2>
2. if tables have different columns then
select col1,col2,.....coln from <table1> [,where....] into <table2>

  Was this answer useful?  Yes

Anonymus

  • Feb 26th, 2007
 

Hey It's NOT working in ORACLE9i. Plz rechecheck and post the query

  Was this answer useful?  Yes

Faizal

  • Feb 28th, 2007
 

create table <New Table Name> as select * from <Old Table Name>;

ex:
create table emp_backup as select * from emp;


  Was this answer useful?  Yes

nagurtilak

  • Mar 15th, 2007
 

there is only one to do that

    in pl/sql we can use Merge Statement

     merge into "targettable name" t
     using  "sourcetablename" s
     on(join condition)
    when matched then
    "------update------"
       when not matched then
   "------insert-----"


  if any query pls ask freely to     nagurcareer@yahoo.co.in
  

dev5000

  • Dec 26th, 2007
 

create table <table name> as select * from <table name>

where the first table name is a new table where you wanted to insert all the records of the other table which you have defined in select statement.

this is another  way of inserting records without using insert command

  Was this answer useful?  Yes

gsmanvi

  • Jun 27th, 2008
 

declare
cursor cursor_name is
select col1,col2,col3
from tab_name;
ab_record cursor_name%rowtype;
begin
open cursor_name;
loop
fetch ab_record into cursor_name;
exit when cursor_name%notfound;
insert into tab_name(col1,col2,col3)
values(ab_record.col1,ab_record.col2,ab_record.col3);
end loop;
commit;
end;

> data type from table1 and table2 must match each other.

Neeraj yadav

  • Oct 3rd, 2011
 

Code
  1. SELECT   *  INTO

  2. tablename_2 FROM tablename_1


OR can pass clause also........................

Code
  1. SELECT   *  INTO

  2. tablename_2 FROM tablename_1

  3. WHERE  VNO='CV/2011/12'

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions