1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

dual

Discussion in 'SQL PL/SQL' started by monkey, Jun 3, 2014.

  1. monkey

    monkey Long Term Member

    Messages:
    156
    Likes Received:
    0
    Trophy Points:
    230
    Hello!
    In the last time often find word "dual", meaning sth like a name of a table???

    What is that really!
    many thanks!!
     
  2. rajenb

    rajenb Forum Expert

    Messages:
    361
    Likes Received:
    114
    Trophy Points:
    655
    Location:
    Mauritius
    "DUAL" is a sort of dummy table (or pseudo table if you wish) with a single record used for selecting when you're not actually interested in the data, but instead want the results of some system function in a select statement:

    For example:
    Code (SQL):
    SELECT SYSDATE FROM DUAL;
     
    monkey likes this.
  3. krasnoslobodtsev_si

    krasnoslobodtsev_si Forum Genius

    Messages:
    626
    Likes Received:
    129
    Trophy Points:
    810
    Location:
    Russian Federation
    Hi.

    Concept

     
    monkey likes this.
  4. monkey

    monkey Long Term Member

    Messages:
    156
    Likes Received:
    0
    Trophy Points:
    230
    Hello!
    So we can write math formula instead of DUMMY?
     
  5. krasnoslobodtsev_si

    krasnoslobodtsev_si Forum Genius

    Messages:
    626
    Likes Received:
    129
    Trophy Points:
    810
    Location:
    Russian Federation
    Yes.
    There is a set of methods of application of the pseudo-table DUAL
     
    monkey likes this.
  6. monkey

    monkey Long Term Member

    Messages:
    156
    Likes Received:
    0
    Trophy Points:
    230
    Hello!
    Does the urser have to create this table (dual) or is it still existing as a default? ( I mean, if all users have access to it, then it probaly stil exists and there is no need to create it as normal tables)
    Many thanks!
     
  7. krasnoslobodtsev_si

    krasnoslobodtsev_si Forum Genius

    Messages:
    626
    Likes Received:
    129
    Trophy Points:
    810
    Location:
    Russian Federation
    Hello.
    The table DUAL is available to all users.
     
  8. monkey

    monkey Long Term Member

    Messages:
    156
    Likes Received:
    0
    Trophy Points:
    230
    Hello!
    MANY THANKS!!!
    Is the value x probably also of any (x) type?
     
  9. rajenb

    rajenb Forum Expert

    Messages:
    361
    Likes Received:
    114
    Trophy Points:
    655
    Location:
    Mauritius
    'X' is a character and the column DUMMY in table DUAL is of type VARCHAR2(1).
     
  10. krasnoslobodtsev_si

    krasnoslobodtsev_si Forum Genius

    Messages:
    626
    Likes Received:
    129
    Trophy Points:
    810
    Location:
    Russian Federation
    Field DUMMY - IS VARCHAR2.

    From the table we always receive, in case of the usual conditions, one record.
    Also it is possible to obtain data of any type.

    For simple example :
    Code (SQL):


    SELECT DUMMY FROM dual ;
    SELECT to_number(10.3) FROM dual;
    SELECT dbms_xmlgen.getxml('select * from dual') xmls  FROM dual;


    SQL>
     
    DUMMY
    -----
    X
     
    TO_NUMBER(10.3)
    ---------------
               10.3



    XMLS
    --------------------------------------------------------------------------------
    <?xml version="1.0"?>
    <ROWSET>
     <ROW>
      <DUMMY>X</DUMMY>
     </ROW>
    </ROWSET>