我们可以限制MySQL中表格的行数吗? [英] Can we limit the number of rows in a table in MySQL?

查看:280
本文介绍了我们可以限制MySQL中表格的行数吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以设置表在MySQL中可容纳的行数? 我不想使用任何Java代码.我想使用纯mysql脚本来做到这一点.

Is it possible to set the number of rows that a table can accommodate in MySQL ? I don't want to use any java code. I want to do this using pure mysql scripts.

推荐答案

除非您有充分的理由,否则我不建议您尝试限制SQL表中的行数.看来使用以下查询会更好:

I wouldn't recommend trying to limit the number of rows in a SQL table, unless you had a very good reason to do so. It seems you would be better off using a query like:

select top 1000 entityID, entityName from TableName

而不是物理上限制表的行.

rather than physically limiting the rows of the table.

但是,如果您确实希望将其限制为1000行:

However, if you really want to limit it to 1000 rows:

delete from TableName where entityID not in (select top 1000 entityID from TableName)

这篇关于我们可以限制MySQL中表格的行数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆