gpt4 book ai didi

mysql - 在现有表中插入新记录时 tt 上升而不是下降

转载 作者:行者123 更新时间:2023-11-29 07:22:49 25 4
gpt4 key购买 nike

我已经创建了表我想添加额外的行当添加额外的行创建的额外行上升。我想要底部的那一行。

MariaDB [armydetails]> insert into armydetails values('r05','Shishir','Bhujel','Jhapa','9845678954','male','1978-6-7','1994-1-3','ran5','Na11088905433');
Query OK, 1 row affected (0.17 sec)

MariaDB [armydetails]> select * from armydetails;
+-------+---------+---------+-----------+------------+--------+------------+------------+--------+----------------+
| regNo | fName | lName | address | number | gender | DOB | DOJ | rankID | accountNo |
+-------+---------+---------+-----------+------------+--------+------------+------------+--------+----------------+
| r05 | Shishir | Bhujel | Jhapa | 9845678954 | male | 1978-06-07 | 1994-01-03 | ran5 | Na11088905433 |
| ro1 | Milan | Katwal | Dharan | 9811095122 | Male | 1970-01-03 | 1990-01-01 | ran1 | Na11984567823 |
| ro2 | Hari | Yadav | Kathmandu | 9810756436 | male | 1980-06-07 | 2000-05-06 | ran2 | Na119876678543 |
| ro3 | Khrisna | Neupane | Itahari | 9864578934 | male | 1980-02-02 | 2001-01-07 | ran3 | Na11954437890 |
| ro4 | Lalit | Rai | Damak | 9842376547 | male | 1989-05-09 | 2005-01-02 | ran4 | Na11064553221 |
+-------+---------+---------+-----------+------------+--------+------------+------------+--------+----------------+
5 rows in set (0.00 sec)

MariaDB [armydetails]>

最佳答案

SQL 2011 publication from ISO/IEC 9075说:

In general, rows in a table are unordered; however, rows in a table are ordered if the table is the result of a that immediately contains an « order by clause ».

在 SQL 数据库中,没有基本的、默认的记录排序。关系数据库基本上将表存储为一堆无序记录。

当记录在没有 ORDER BY 子句的情况下被 SELECTed 时,它们以未定义的顺序出现,这绝不能保证在后续查询中保持一致(包括同一个查询被执行了多次)。对于 MySQL 对于其他 RDBMS 都是如此。

正确排序记录的唯一方法是使用 ORDER BY 子句,例如:

select * from armydetails order by regNo

建议讲座:Tom Kyte Blog : Order in the Court! .

关于mysql - 在现有表中插入新记录时 tt 上升而不是下降,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55309461/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com