对 oracle 表中的数据进行排序

发布于 2024-10-10 04:13:24 字数 64 浏览 1 评论 0原文

是否可以对 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

你是暖光i 2024-10-17 04:13:24

您可以尝试

Select *
from some_table
order by some_column asc

这将按 some_column 对结果进行排序,并将它们按升序排列。如果您想要降序排列,请使用 desc 而不是 asc。或者您的意思是在物理存储本身中进行排序?

我相信可以指定存储中索引列的排序/排序。它可能最接近您想要的。我通常不使用此索引排序功能,但有关详细信息,请参阅:http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_5010.htm#i2062718

You could try

Select *
from some_table
order by some_column asc

This will sort the results by some_column and place them in ascending order. Use desc instead of asc 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

余生再见 2024-10-17 04:13:24

也许您可以使用索引组织表 - 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.

枉心 2024-10-17 04:13:24

根据关系模型的定义,表中的行和列是无序的。至少理论上是这样。

实际上,如果您希望数据以特定顺序从查询中出来,那么您应该始终使用 ORDER BY 子句。除非您提供,否则无法保证输出的顺序。

插入表时可以使用 ORDER BY,但这并不能保证数据的输出顺序。查询可能每次都会以相同的顺序出现......但这并不意味着下次它会以相同的顺序出现。

Oracle 10g 推出时存在一些问题,聚合查询(使用 GROUP BY)未进行排序,因为用户开始依赖数据排序作为分组的副作用。随着 HASH GROUP BYSORT 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 the HASH GROUP BY in addition to the SORT GROUP BY people were caught out. This was a useful reminder that ORDER BY should always be used.

じ违心 2024-10-17 04:13:24

你到底是什么意思?

您只是要求 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

凉月流沐 2024-10-17 04:13:24

Oracle 10g Express 像大多数 RDBM 一样支持 ANSI SQL,因此您可以按照标准方式进行排序:

SELECT * FROM Persons ORDER BY LastName

可以在此处找到有关 SQL 的优秀教程:w3schools SQL

与企业版相比,Oracle Express 确实有一些限制,但在它支持的基本 SQL 方言中没有。

Oracle 10g Express supports ANSI SQL like most RDBM's so you can sort in the standard manner:

SELECT * FROM Persons ORDER BY LastName

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文