Copying a Table : Copy Table « Table Index « SQL / MySQL






Copying a Table

  
/*create a copy of a table so that you
can alter it or experiment with it without endangering the original
data
*/

CREATE TABLE new_table_name
SELECT * FROM old_table_name;

/* Differences: their names, 
               if the old table had an index (or key), it
does not transfer to the new table. 
only two columns chosen
*/
           
         
    
  








Related examples in the same category

1.Copy Table Demo
2.Copy Table with Condition
3.Use NULL in where clause
4.Copy table with conditions
5.Only copy records
6.Using the INSERT Statement to Copy Data
7.Using the REPLACE Statement to Copy Data
8.Copy a table
9.Only copy certain columns
10.Copy one row of data
11.Copy data to temporary table
12.Creating New Tables with SELECT Results
13.Copying Only Selected Data from a Table
14.Copy table with calculation
15.Copying Data into a New Table
16.MySQL truncates the data during copying