[英]sql delete from start
无论如何,我可以将表中允许的行数限制为40,然后在添加41st时,表删除第一个?
Yes, you could do this with a trigger. 是的,您可以使用触发器来执行此操作。 What RDMS are you using?
您正在使用什么RDMS?
CREATE TABLE animals (
id MEDIUMINT NOT NULL AUTO_INCREMENT,
name CHAR(30) NOT NULL,
PRIMARY KEY (id)
);
-- if this is 41st record, ...
-- the statement below will delete the id with 1, and so forth
insert into animals(name) values('wolverine');
delete from animals where id <= LAST_INSERT_ID() - 40;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.