How to copy one table data into another table directly?

Showing Answers 1 - 9 of 9 Answers

chandra

  • Oct 12th, 2007
 

Syntax to copy the structure of the one table into another table.

syn: select * into newtablename from oldtablename where false condition

ex: select * into dept1 from dept where 1=9

sytanx to copy one table data into another table.

syn:  insert into newtable name select * from old tablename

ex: insert into dept1 select * from dept.

  Was this answer useful?  Yes

We can copy the Table structure also from one table to another table

Example:
                   CREATE table emp1 as
                   SELECT * from emp
                   WHERE 1=2;

we can copy a data from one table to another table

While copying the data we should be careful in few things

1. Both the table Structure should be same

2. The DataType of all the Columns of the both table should be  same

Example:

                 INSERT INTO emp1 VALUES as
                 SELECT *
                 FROM emp



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