Copying Rows from another Table:
You can use the Insert Statement to add rows to a table where the values are derived from existing tables.In place of the values clause,you can use the subquery.
Syntax:Insert into table [ column (,column)] subquery;
In the Syntax:table
is the tablenamecolumn
is the name of the column in the table to populatesubquery
is the subquery that returns rows into the table
The nimber of columns and their datatypes in the column list of the INSERT clause must match the number of values and their data types in the seubquery.To create a copy of the rows of a table,use
Select * in the subquery.Insert into copy_emp(id,name,salary)
Select * from employees; Note:
1.Donot use the VALUES clause.
2.Match the number of columns in the INSERT clause to those in the Subquery.