当前位置:网站首页>How SQLite limits the total number of data in a table
How SQLite limits the total number of data in a table
2022-06-12 07:55:00 【Ruoyun Liufeng】
1、 Do it regularly :
DELETE FROM table where _id NOT IN (SELECT _id from table ORDER BY insertion_date DESC LIMIT 50)
2、 Or build a trigger:
CREATE TRIGGER delete_till_50 INSERT ON _table WHEN (select count(*) from _table)>50
BEGIN
DELETE FROM _table WHERE _table._id IN (SELECT _table._id FROM _table ORDER BY _table._id limit (select count(*) -50 from _table ));
END;2.1 explain :
a. The trigger condition :
INSERT ON _table WHEN (select count(*) from _table)>50
When inserting a table, check whether the total number of entries is greater than 50, If it is greater than 50 Then start .
b. Delete data
DELETE FROM _table WHERE _table._id IN (SELECT _table._id FROM _table ORDER BY _table._id limit (select count(*) -50 from _table ));
1. Find out what you want to delete id:DELETE FROM _table WHERE _table._id IN
2. Delete from the earliest , Save only the latest 50 strip : Limit the number of queries ,limit (select count(*) -50 from _table ). Yes id Sort , Of course, it can also be sorted by time .
Reference resources :sqlite How to limit the total number of data in a table _love_android_2011 The column -CSDN Blog
边栏推荐
- Leetcode notes: Weekly contest 296
- Voice assistant - those classification models used in the assistant
- Parameter estimation of Weibull distribution
- Topic 1 Single_Cell_analysis(2)
- Voice assistant - Multi round conversation (process implementation)
- Latex usage problems and skills summary (under update)
- AJ project: online bank project summary
- Utilize user tag data
- Support vector machine (SVM)
- Cold start problem of recommended system
猜你喜欢

Summary of semantic segmentation learning (I) -- basic concepts
![FPGA based communication system receiver [packet detection] development document](/img/50/0d15abc41c6e373b00fa05e299566a.jpg)
FPGA based communication system receiver [packet detection] development document

Topic 1 Single_Cell_analysis(1)

Voice assistant - DM - distribution and sorting

Voice assistant - Multi round conversation (theory and concept)

Vs 2019 MFC connects and accesses access database class library encapsulation through ace engine

Generalized semantic recognition based on semantic similarity

Topic 1 Single_Cell_analysis(2)

Voice assistant -- Architecture and design of Instruction Assistant

Voice assistant - Introduction and interaction process
随机推荐
2021.10.29-30 scientific research log
Voice assistant - Multi round conversation (theory and concept)
In depth learning - overview of image classification related models
20220607. face recognition
R语言e1071包的naiveBayes函数构建朴素贝叶斯模型、predict函数使用朴素贝叶斯模型对测试数据进行预测推理、table函数构建混淆矩阵
2D visualization of oil storage, transportation and production, configuration application enables intelligent development of industry
Utilize user behavior data
[tutorial] deployment process of yolov5 based on tensorflow Lite
Kalman filter encapsulation function
Chapter V - message authentication and digital signature
Latex usage problems and skills summary (under update)
Parameter estimation of Weibull distribution
20220525 RCNN--->Faster RCNN
2021.11.3-7 scientific research log
2021.10.24-25 scientific research log
Work summary of the week from November 22 to 28, 2021
Leetcode34. find the first and last positions of elements in a sorted array
Preliminary knowledge next New concepts such as isr/rsc/edge runtime/streaming in JS
20220524 deep learning technology points
Topic 1 Single_Cell_analysis(2)