question

BI DWH BALA avatar image
BI DWH BALA asked

What is the Oracle equivalent of "Dual" table in SqlServer?

Hi,

What is the Oracle equivalent of "Dual" table in SqlServer?

Thanks in advance.

Regards, BI DWH BALA

oracle-sql-developer
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Christian13467 avatar image
Christian13467 answered

There is no equivalent.

DUAL is introduced to be SQL standard conform. In sql server you can leave the table if there is none in select statement.

Oracle

SELECT sysdate FROM DUAL;

SQL server

SELECT getdate();

The two statements above to select the current date show the different usage.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

BI DWH BALA avatar image BI DWH BALA commented ·
Thank you so much Christian.
0 Likes 0 ·
KillerDBA avatar image
KillerDBA answered

It doesn't exist but... you could create one if you wanted to be able to code consistently across different platforms.

create table dual (dual int)
go
insert values (1)
go
select getdate() from dual
-- returns 2009-12-03

You'd probably want to add a default of 1, add a constraint that it must be 1 and a PK. And maybe a trigger that prevents deleting the record. I'm not sure if there are any other conditions to look out for and defend against. If the table contained 0 or more than 1 rows, you wouldn't get just one date value returned.

IBM DB2 has a similar table which I believe is called sysibm.sysdummy.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.