对 oracle 表中的数据进行排序
是否可以对 oracle 表内的数据进行排序?就像按字母顺序按某个列升序/降序一样。 Oracle 10g 快递。
Is it possible to sort the data inside of an oracle table? Like ascending/descending via a certain column, alphabetically. Oracle 10g express.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以尝试
这将按
some_column
对结果进行排序,并将它们按升序排列。如果您想要降序排列,请使用desc
而不是asc
。或者您的意思是在物理存储本身中进行排序?我相信可以指定存储中索引列的排序/排序。它可能最接近您想要的。我通常不使用此索引排序功能,但有关详细信息,请参阅:http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_5010.htm#i2062718
You could try
This will sort the results by
some_column
and place them in ascending order. Usedesc
instead ofasc
if you want descending order. Or did you mean to have the ordering in the physical storage itself?I believe it's possible to specify the ordering/sorting of an indexed column in storage. It's probably closest to what you want. I don't usually use this index sort feature, but for more info see: http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_5010.htm#i2062718
也许您可以使用索引组织表 - IOT 来确保数据按索引排序存储。
看一下 CREATE TABLE 语句的物理属性子句:
http://download.oracle.com/docs /cd/B19306_01/server.102/b14200/statements_7002.htm#i2128663
您试图解决的问题是什么?物联网可能是也可能不是您应该使用的。
Perhaps you could use an index organized table - IOT to ensure that the data is stored ordered by index.
Have a look at the physical properties clause of the CREATE TABLE statement:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7002.htm#i2128663
What is the problem that you are trying to solve though? An IOT may or may not be what you should be using.
根据关系模型的定义,表中的行和列是无序的。至少理论上是这样。
实际上,如果您希望数据以特定顺序从查询中出来,那么您应该始终使用
ORDER BY
子句。除非您提供,否则无法保证输出的顺序。插入表时可以使用 ORDER BY,但这并不能保证数据的输出顺序。查询可能每次都会以相同的顺序出现......但这并不意味着下次它会以相同的顺序出现。
Oracle 10g 推出时存在一些问题,聚合查询(使用
GROUP BY
)未进行排序,因为用户开始依赖数据排序作为分组的副作用。随着HASH GROUP BY
和SORT GROUP BY
的引入,人们陷入了困境。这是一个有用的提醒,应始终使用ORDER BY
。As defined by the relational model, the rows and columns in a table are unordered. That's the theory at least.
In practice, if you want the data to come out of a query in a particular order then you should always use the
ORDER BY
clause. The order of the output is not guarantee unless you provide that.It would be possible to use an
ORDER BY
when inserting into a table but that doesn't guarantee the order that data will be output. A query might come out in the same order every time.... but that doesn't mean it will come out in the same order next time.There were issues when Oracle 10g came out where aggregate queries (with
GROUP BY
) were not coming out sorted because users had come to rely on the data being sorted as a side-effect of the grouping. With the introduction of theHASH GROUP BY
in addition to theSORT GROUP BY
people were caught out. This was a useful reminder thatORDER BY
should always be used.你到底是什么意思?
您只是要求 order by 子句吗?
http://www.1keydata.com/sql/sqlorderby.html
What do you really mean ?
Are you just asking for the order by clause ?
http://www.1keydata.com/sql/sqlorderby.html
Oracle 10g Express 像大多数 RDBM 一样支持 ANSI SQL,因此您可以按照标准方式进行排序:
可以在此处找到有关 SQL 的优秀教程:w3schools SQL
与企业版相比,Oracle Express 确实有一些限制,但在它支持的基本 SQL 方言中没有。
Oracle 10g Express supports ANSI SQL like most RDBM's so you can sort in the standard manner:
A good tutorial on SQL can be found here: w3schools SQL
Oracle Express does have some limitations compared to the Enterprise Edition but not in the basic SQL dialect it supports.