Home > database >  How time the input of a table of data in mysql to another table?
How time the input of a table of data in mysql to another table?

Time:10-04

Specific requirements is
Have two table history table table that month two table table structure identical
At the beginning of each month, submit a month's worth of table data is exported to the history table table that month to empty

Specific what to do?

CodePudding user response:

Early server timed script performs a
Transaction export import excel
After finish empty table during the month

CodePudding user response:

A month do you can use the event or the timing of the operating system task
Move data can refer to this (building a structure to replace the current table with the same current table, and then put data into the history table)
The create table _ month table LIKE the current table;
Rename the table of the current table to _ the history table, _ table to table that month that month;
Insert the history table select * from _ history table;
Drop table _ history table;

CodePudding user response:


Junction post rate: 0%

When you the solutions of the problems please post.
http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
http://topic.csdn.net/u/20100428/09/BC9E0908-F250-42A6-8765-B50A82FE186A.html
http://topic.csdn.net/u/20100626/09/f35a4763-4b59-49c3-8061-d48fdbc29561.html

8, how to give points and knot stick?
http://bbs.csdn.net/help#post_dispose

CodePudding user response:

The mysql event function can you use to do,

You can put the specific operation: insert into history table select * from real time table where the data of last month, and then delete from the fact table where the data of last month, in a stored procedure, and call the stored procedure on the event

CodePudding user response:

When your two tables of data structure is the same, you can use the insert into the target table select * from the source table and then delete the data of target table, finally with a fee to timing task execution, mysql is upstairs said the event, thanks to the upstairs said the event is under study

CodePudding user response:

- the history table: History_Table, table that month: Current_Table;
Use mysql event function for:

The Create TABLE Current_Table1 LIKE Current_Table;
INSERT INTO History_table SELECT * FROM Current_Table;
DROP TABLE Current_TABLE;
RENAME TABLE Current_Table1 Current_Table),
  • Related