In this lesson we are going to study about how to copy a data from one table to another table.
Syntex:
Insert into Table_name (column1,column2,....,columnN) Subquery
here insert is a keyword and into specify the table in which we are going to insert the data and Table_name specify the name of the table ,column1,column2,...,columnN is the name of columns.
Example:
Consider a table : departments.
Now we have created a table: dept with same columns.
create table dept
(id number(7),
name varchar2(25)
)
We can copy the rows in a insert statement.here we are going to insert the data in newly create dept table from the table departments
insert into dept (id,name)
(select department_id as id,department_name as name
from departments)
In this insert statement we have written a select statement as subquery.In the select statement we have selected the department_id and given the alias name id,and department_name with alias name name.
I am interested in hearing your feedback, so that I can improve my articles and learning resources for you.connect with us on facebook, twitter
No comments:
Post a Comment