Creating SQL Table from another table


Often we need to take quick backup of database with data before we can make changes in table. for this I create the image of table within same database, as it is the fastest method. It is one of the reason why one need to create image a table.. or copy one table from another.

It can be achieved in all RDBMS

Here is SQL for MS SQL

select * into newTable from OldTable

However, their is another command (it works for me on mysql)

create table newtable as (select * from oldtable)

Best of luck with backup and server transfers.

,

One response to “Creating SQL Table from another table”

  1. I just discover another method for it.

    Select * Into Newtable From OldTable {Rest of condition and joings follows}

    This statement redirect your output of normal Select query to create a new table called newtable.