SQL copy table to another table

SqlServer copy table structure and table data

Copy the table data to existing tables
 INSERT INTO targetTableName SELECT COLUMNS FROM sourceTableName;
Copy table structure and data to the new table
 SELECT COLUMNS  
 INTO  newTableName
 FROM  sourceTableName
 where whereExpression ;

note:

This statement can only copy the structure of the table. This statement does not create the same copy source primary keys, indexes, constraints and triggers.

Oracle copy table structure and table data

Copy the table data to existing tables
 INSERT INTO targetTableName SELECT COLUMNS FROM sourceTableName;
Copy table structure and data to the new table
 CREATE TABLE newTableName AS SELECT COLUMNS FROM sourceTableName  where whereExpression;

note:

This statement can only copy the structure of the table. This statement does not create the same copy source primary keys, indexes, constraints and triggers.

Mysql replication table structure and table data

Copy the table data to existing tables
     INSERT INTO targetTableName SELECT COLUMNS FROM sourceTableName;
Copy table structure and data to the new table
CREATE TABLE targetTable LIKE sourceTable;


CREATE TABLE newTableName AS (SELECT COLUMNS FROM sourceTableName  where whereExpression);

note:

This statement can only copy the structure of the table. This statement does not create the same copy source primary keys, indexes, constraints and triggers.

Guess you like

Origin www.cnblogs.com/xgzh/p/11269009.html