简体   繁体   English

Mariadb - 如何通过查询删除历史记录?

[英]Mariadb - How to delete history by query?

My Mariadb Version : 10.3.23我的 Mariadb 版本:10.3.23

Problem: My server's disk is reaching saturation point soon, I got many useless history data in my database.问题:我的服务器磁盘即将达到饱和点,我的数据库中有很多无用的历史数据。 My table is created with SYSTEM VERSIONING.我的表是使用系统版本创建的。 I want delete the useless history data by query like below:我想通过如下查询删除无用的历史数据:

DELETE HISTORY FROM my_table FOR SYSTEM_TIME ALL where my_table.id = 2152 

I got error message :我收到错误消息:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SYSTEM_TIME ALL where writing_id= 2152'

Question: How to delete useless historical data associated with a id ?问题:如何删除与 id 关联的无用历史数据?

Correct syntax for deleting useless history is described in User Manual , for example, if you want to remove versions with the age of a month or above use: 用户手册中描述了删除无用历史的正确语法,例如,如果您想删除月龄或以上的版本,请使用:

DELETE HISTORY 
    FROM table_name 
    BEFORE SYSTEM_TIME (CURRENT_DATE - INTERVAL 1 MONTH);

You cannot delete versioning history for separate rows.您不能删除单独行的版本控制历史记录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM