Select without a FROM clause in Oracle(在 Oracle 中不使用 FROM 子句进行选择)
问题描述
在SQL Server中可以执行SELECT,而无需参考表;类似:
选择 1.2 +3, 'my dummy string'由于Oracle 不允许没有FROM 的SELECT,因此我使用双表进行此类操作;类似:
从 DUAL 中选择 1,2+3, 'my dummy string'有没有更好的方法来做这种类型的查询?使用双表是个好习惯吗?
不,在Oracle中没有SELECT没有FROM.
使用 dual 表是一个好习惯.
dual 是一个内存表.如果您不从中选择 DUMMY,它将使用不需要 I/O 的特殊访问路径 (FAST DUAL).>
曾几何时,dual 有两条记录(因此得名),旨在作为虚拟记录集来复制被连接的记录.
现在它只有一条记录,但你仍然可以用它生成任意数量的行:
SELECT 级别从双联系方式等级 <= 100MySQL 还支持 dual(以及 fromless 语法).
in SQL Server is possible to execute a SELECT, without reference to a table; something like:
Select 1.2 +3, 'my dummy string'
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?
No, in Oracle there is no SELECT without FROM.
Using the dual table is a good practice.
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.
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 also supports dual (as well as the fromless syntax).
这篇关于在 Oracle 中不使用 FROM 子句进行选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Oracle 中不使用 FROM 子句进行选择
基础教程推荐
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 无法解决整理冲突 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
