如何在sqlite db中禁用排序 [英] How to disable sorting in sqlite db

查看:103
本文介绍了如何在sqlite db中禁用排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi


我在向sqlite db插入数据时遇到了麻烦。当我向表中插入数据时,它会自动按升序排序。我需要禁用那个。请帮助



谢谢



我的尝试:



我试图在代码中更改数据库的排序规则但仍无法正常工作

hi
I have a trouble in inserting data to sqlite db .when am inserting data to table it is automatically sorting in ascending order.I need to disable that one.please help

Thanks

What I have tried:

I have tried to change db's collation in code but still not working

推荐答案

除非您使用ORDER BY指定订单在SELECT语句中,系统可以按任何顺序返回行。通常,这相当于先进先出序列,因此您的最新插入将是最后一次 - 但这不能保证,您可以使用两个相同的SELECT语句获得不同的结果(这对于像SqLite这样的单用户系统来说不太可能比像SQL Server这样的多用户,但它应该在你的设计中考虑。)



如果你想要一个不同的订单,那么你必须用ORDER专门要求它BY子句:

Unless you specify an order with an ORDER BY clause in your SELECT statement, the system is at liberty to return rows in any order it wants. Normally, this equates to "first in, first out" sequence, so your latest inserts will be last - but that isn't guaranteed and you can get different results with two identical SELECT statements (this is less likely with single user systems like SqLite than multiuser like SQL Server, but it should be considered in your design).

If you want a different order, then you have to specifically ask for it with an ORDER BY clause:
SELECT <my list of columns> 
FROM MyTable 
WHERE <my condition>
ORDER BY <my list of columns to sort by> <ASC or DESC for direction>



例如:


For example:

SELECT UserID, UserName FROM MyTable ORDER BY BirthDate DESC


这篇关于如何在sqlite db中禁用排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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