Monday 25 November 2013

INSERTING ROWs INTO TABLE FROM SELECTING ROWS FROM ANOTHER TABLE

Bismillahir Rahmanir Raheem

We will insert rows into a table from retreiving rows from another table

Create table table1(id number,name varchar2(20));

insert into table1 values(111,'Mahtab Alam');
insert into table1 values(222,'Aftab Alam');
insert  into table1 values(333,'Sdre Alam');

Now we have three rows in table1 .
Lets add these rows into table2

create table table2(RollNo number,Student_name varchar2(20));

insert into table2
select id,name
from table1;

or

create table table3(pid number);

insert into table3(pid)
select id
from table1;

No comments:

Post a Comment