Copy data between tables with the same structure and different names after Mysql is divided into tables, and the Update statement only updates the date plus or minus without changing the time

Scenes

SpringBoot+Mybatis+timed tasks realize large data volume data sub-table recording and query:

SpringBoot+Mybatis+Timed Task Realizes Recording and Querying of Large Data Volume Data Tables

How to copy the data in a table between the tables with the same structure and different table names realized through the above sub-tables

In another table, the date field is added in the same way, and the time field remains unchanged.

Note:

Blog:
Domineering Rogue Temperament_C#, Architecture Road, SpringBoot-CSDN Blog

accomplish

1. For example, copy the data in the bus_vehicle_position_record20230731 table to the bus_vehicle_position_record20230801 table

Export the bus_vehicle_position_record20230731 table as a sql file through Navicat and other software, and edit the file.

 

First use the global replacement function to replace the table name in the Insert statement globally.

2. After the replacement, run sql into the bus_vehicle_position_record20230801 table

At this time, you need to update the time field in the bus_vehicle_position_record20230801 table, add one day to the date, and keep the time unchanged. You can execute the following sql

UPDATE bus_vehicle_position_record20230801
SET record_date = DATE_ADD(record_date, INTERVAL 1 DAY)

At this time, the date of the record_date field is all added by one day, but the time remains unchanged.

Guess you like

Origin blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/132342164