Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Data Management

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Your profile

    Search

    XML Feeds

    Google Ads

    « Truncate rollback differences between SQL Server and OracleDifferences between Oracle and SQL Server when working with NULL and blank values »
    comments

    When coming from SQL Server, you might find it weird that you don't see code that looks like this in Oracle's PL/SQL

    1. SELECT 2
    2.  
    3. SELECT SYSDATE --  getdate()in SQL Server

    Unlike with SQL Server that code won't run in Oracle, Oracle requires the use of the FROM clause in its syntax. This is why Oracle has the DUAL table.

    If you try to run something like this

    you will get the following error

    ORA-00923: FROM keyword not found where expected
    00923. 00000 - "FROM keyword not found where expected"

    I decided to see where the Dual table came from.

    From wikipedia

    The DUAL table was created by Charles Weiss of Oracle corporation to provide a table for joining in internal views:

    I created the DUAL table as an underlying object in the Oracle Data Dictionary. It was never meant to be seen itself, but instead used inside a view that was expected to be queried. The idea was that you could do a JOIN to the DUAL table and create two rows in the result for every one row in your table. Then, by using GROUP BY, the resulting join could be summarized to show the amount of storage for the DATA extent and for the INDEX extent(s). The name, DUAL, seemed apt for the process of creating a pair of rows from just one.

    The original DUAL table had two rows in it (hence its name), but subsequently it only had one row.

    Running the following code

    Give you a resultset of 1 row with 1 column named DUMMY with the value X

    So there you have it, this is why the Dual table exists.

    If you need to do something like this

    1. SELECT 3/2

    in Oracle it needs to be

    However Oracle returns 1.5 while SQL Server will return 1, SQL Server does integer math and Oracle does not. That is another difference you need to be aware of, this is more problematic when moving from Oracle SQL Server and then wondering where all the decimals went.

    About the Author

    User bio imageDenis has been working with SQL Server since version 6.5. Although he worked as an ASP/JSP/ColdFusion developer before the dot com bust, he has been working exclusively as a database developer/architect since 2002. In addition to English, Denis is also fluent in Croatian and Dutch, but he can curse in many other languages and dialects (just ask the SQL optimizer) He lives in Princeton, NJ with his wife and three kids.
    Social SitingsTwitterFacebookLinkedInHomePageFlickrLTD RSS Feed
    1595 views
    InstapaperVote on HN

    1 comment

    Comment from: Axel Achten (axel8s) [Member]
    Axel Achten (axel8s) I had to migrate an Oracle db to SQL Server a couple of years ago. I searched half an hour after the dual table, view, function or whatever it could be. Then I asked the Oracle DBA and he started laughing...
    01/07/13 @ 02:51

    Leave a comment


    Your email address will not be revealed on this site.

    To mislead the spambots.

    Your URL will be displayed.
    (Line breaks become <br />)
    (Name, email & website)
    (Allow users to contact you through a message form (your email will not be revealed.)