在Oracle中不带FROM子句的选择

在Oracle中不带FROM子句的选择

本文介绍了在Oracle中不带FROM子句的选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以执行SELECT,而无需引用表;像这样:

in SQL Server is possible to execute a SELECT, without reference to a table; something like:

Select 1.2 +3, 'my dummy string'

由于 Oracle 不允许在没有FROM的情况下进行SELECT,因此我将对偶表用于这种类型的操作;像这样:

As Oracle does not allow a SELECT without a FROM, I use the dual table for this type of operation; something like:

Select 1,2+3, 'my dummy string' FROM DUAL

有没有更好的方法来进行这种类型的查询?最好使用双重表格?

There is a better way of doing this type of query? it is good practice to use the dual table?

推荐答案

不,在Oracle中没有FROMSELECT.

使用dual表是一个好习惯.

dual是内存表.如果未从中选择DUMMY,它将使用特殊的访问路径(FAST DUAL),该路径不需要I/O.

dual is an in-memory table. If you don't select DUMMY from it, it uses a special access path (FAST DUAL) which requires no I/O.

从前,dual具有两个记录(因此而得名),并打算用作虚拟记录集来复制与之连接的重复记录.

Once upon a time, dual had two records (hence the name) and was intended to serve as a dummy recordset to duplicate records being joined with.

现在它只有一条记录,但是您仍然可以用它生成任意数量的行:

Now it has but one record, but you can still generate an arbitrary number of rows with it:

SELECT  level
FROM    dual
CONNECT BY
        level <= 100

MySQL还支持dual(以及fromless语法).

MySQL also supports dual (as well as the fromless syntax).

这篇关于在Oracle中不带FROM子句的选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-21 00:17