在Oracle中不参考双重表就从中选择吗? [英] Select from nothing in Oracle without referencing the dual table?
问题描述
在引用双重表时(例如,
selecting from nothing in Oracle SQL happens while referencing the dual table, like
SELECT sysdate FROM dual;
现在,我希望有一个对PostgreSQL也适用的查询,但是不可能从双查询中进行选择.我知道我可以删除整个FROM
部分,但是在Oracle中将无法使用.
Now I'd like to have a query that also works for PostgreSQL, but selecting from dual there isn't possible. I know that I can drop the whole FROM
part, but then it won't work in Oracle.
我也尝试过类似SELECT CURRENT_TIMESTAMP FROM VALUES(1)) V(C);
之类的事情,但是Oracle也无法做到这一点.
I've also tried things like SELECT CURRENT_TIMESTAMP FROM VALUES(1)) V(C);
, but Oracle can't do this, either.
那么有没有一种方法可以在不使用Oracle SQL中的dual
表的情况下从任何地方进行选择?
So is there a way to select from nowhere without using the dual
table in Oracle SQL?
推荐答案
或者,在Postgres中创建一个名为dual
的表,该表由1行1列组成
Alternatively, create a table named dual
in Postgres, made of 1 row and 1 column
create table dual as (select 1);
,您可以像在Oracle中那样在Postgres中使用它
and you can use it in Postgres as you would in Oracle
select 'whatever' from dual;
?column?
-----------
whatever
这篇关于在Oracle中不参考双重表就从中选择吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!