[英]sqlite3, How do I insert the value at the position of second row
This is my existing table 这是我现有的桌子
1|Dennis|456731|NOT CONNECTED|NOT FAVORITE
2|MOTO|4568971|NOT CONNECTED|NOT FAVORITE
3|KARBAN|4568971|CONNECTED|NOT FAVORITE
4|Lenovo|4568971|CONNECTED|NOT FAVORITE
How do I insert the new value at the position of second row. 如何在第二行的位置插入新值。
1|Dennis|456731|NOT CONNECTED|NOT FAVORITE
2|Gosling|456731|NOT CONNECTED|NOT FAVORITE
3|MOTO|4568971|NOT CONNECTED|NOT FAVORITE
4|KARBAN|4568971|CONNECTED|NOT FAVORITE
5|Lenovo|4568971|CONNECTED|NOT FAVORITE
SQL tables generally do not have any inherent order (well, there is the notion of an ordered clustered index, but generally we cannot rely on this). SQL表通常不具有任何内在的顺序(当然, 有一个有序的聚集索引的概念,但一般我们不能依靠这一点)。 So, if you want the new
Gosling
record to appear second, then you should provide some column which generates this order. 因此,如果您希望新的高
Gosling
记录出现在第二位,则应提供一些生成此顺序的列。
Your expected output almost looks like it is sorted alphabetically by name. 您的预期输出几乎看起来像是按名称的字母顺序排序。 So, the following query might be acceptable to you:
因此,您可以接受以下查询:
SELECT *
FROM yourTable
ORDER BY name;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.