Thursday, March 15, 2012

how to copy data from one table to another table in mysql


INSERT  INTO  TABLE2  SELECT  *  FROM  TABLE1

INSERT INTO TABLE2 (COL1, COL2, COL3) SELECT COL1, COL4, COL7 FROM TABLE1

copy table one database to another database 

CREATE TABLE database2.`tablename2` SELECT * FROM database1.`tablename1`

NOTE:
 it must you have database1 , database2 and tablename1
 
Create similar table in mysql 
CREATE TABLE new_table_name LIKE tablename2;

rename table in mysql 
RENAME TABLE   table1 TO  table2  ;



No comments:

Post a Comment

If you Satisfied , Please Leave a comment