插入中间行的新数据意外(new data inserted in the middle rows accident)

编程入门 行业动态 更新时间:2024-10-20 05:38:27
插入中间行的新数据意外(new data inserted in the middle rows accident)

我只是在我的网站中插入一个带有表单的数据,通常数据会插入到最后一行中,如:auto_increment name

1 a 2 b 3 c 4 d 5 e

但是,当我上次插入新数据时,它插入到表的中间行,看起来像:

17 data17 30 data30 18 data18 19 data19 20 data20

已插入表格中间行的最新数据(data30)。 我很少发生(仍然发生)为什么会发生这种情况? 以及我将来如何防止这件事? 谢谢。

I just insert a data with a form in my website, normally the data will inserted in the last of rows like : auto_increment name

1 a 2 b 3 c 4 d 5 e

but, when i insert a new data last time, it inserted in the middle rows of table, looked like :

17 data17 30 data30 18 data18 19 data19 20 data20

the newest data that has been inserted in the middle rows of table (data30). it's happen to me rarerly (still happen) why this happen? and how i prevent this thing in in the future? thankyou.

最满意答案

你看到的是引擎返回的结果。 这不是一个早期提取的问题,后来因为它取决于很多问题。 首先,不要认为您的数据库表是FoxPro等顺序文件。 它比那更复杂。 接下来,对于返回数据的每个查询,请使用Order by子句来避免这些实例。

所以总是使用:

select columns from table order by column

以上内容将确保您以所需的方式获取数据,并且当数据库引擎在缓存中找到后续记录时从而从另一个数据库文件中的慢速介质中获取旧记录时,不会感到惊讶。 如果您阅读了RDBMS概念的基础知识,那么就会讨论这些内容,您还需要研究MySQL内部的工作原理。

我发现这篇很棒的文章讨论了现代数据库查询引擎的许多精彩功能。 http://thinkingmonster.wordpress.com/mysql/mysql-architecture/

尽管整篇文章都讨论了这个主题,但您可能会特别关注有关Record Cache的部分。

What you see is the result returned by the engine. It is hardly a matter which recod is fetched early and which later as it depends on a lot of issues. For one, dont think your database table to be a sequential file like FoxPro. It is way more sophisticated than that. Next, for every query that returns data use a Order by clause to avoid these instances.

So always use:

select columns from table order by column

The above will ensure you get the data the way you need and not be surprised when the DB engine finds a later record in cache while fetches an older record from a slow media in another database file. If you read the basics of RDBMS concepts then these things are discussed as also you need to study how MySQL internally works.

I found this great article that discusses the many wonderful features of a modern database query engine. http://thinkingmonster.wordpress.com/mysql/mysql-architecture/

Although the entire article discusses the topic very well but you may pay extra attention to the section that talks about Record Cache.

更多推荐

本文发布于:2023-08-01 13:51:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1359180.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:意外   数据   data   inserted   rows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!