I need to transfer all data of one table to another dumping table. My purpose is to get table ready for daily transaction and previous data should be moved to another table which stores every days data. i need mysql syntax for this, thank you in advance for your support and help
Asked
Active
Viewed 369 times
0
-
Does this answer your question? [Move SQL data from one table to another](https://stackoverflow.com/questions/1612267/move-sql-data-from-one-table-to-another) – Pratik Bhajankar Nov 20 '19 at 07:50
1 Answers
1
You can try these queries:
This query will copy the data and structure, but the indexes are not included:
CREATE TABLE new_table SELECT * FROM old_table;
To copy everything, including database objects such as indexes, primary key constraint, foreign key constraints, triggers run these queries:
CREATE TABLE new_table LIKE old_table;
INSERT new_table SELECT * FROM old_table;
To insert data into an existing table, use this :
INSERT INTO table2 SELECT * FROM table1

Prabhjot Singh Kainth
- 1,831
- 2
- 18
- 26
-
i need to move data into existing table rather creating new table – Dilip Dangoriya Nov 20 '19 at 06:31
-
@DilipDangoriya I have updated the answer, kindly check. It is without any loop. – Prabhjot Singh Kainth Nov 20 '19 at 06:35