Friday, May 27, 2011

Create a Table Copy in SQL

Many times what we need to do is just want to create a table backup (with data) in our database.

Suppose you have a table named PURCHASE_ORDER, and you need to create a backup of the table. Use the following query.

select * into PURCHASE_ORDER_BAK from PURCHASE_ORDER

The above query will create a backup table PURCHASE_ORDER_BAK and will copy all data from PURCHASE_ORDER to the table. I have tested the above query on SQL Server and I believe same should work on ORACLE as well as MYSQL

No comments:

Post a Comment