zoukankan      html  css  js  c++  java
  • sql: DUAL

    FROM <<Oracle.Database.11g.SQL>>

    dual is a table that contains a single row. The following output from the DESCRIBE command shows the structure of the dual table, along with a query that retrieves the row from the dual table:

    DESCRIBE dual
    Name Null? Type
    ----------------------------------------- -------- -----------
    DUMMY VARCHAR2(1)
    
    SELECT *
    FROM dual;
    D
    -
    X
    

    Notice the dual table has one VARCHAR2 column named dummy and contains a single row with the value X.

    -------------

    SELECT TO_DATE('02-AUG-2007') - 3
    FROM dual;
    TO_DATE('
    ---------
    30-JUL-07
    
    You can also subtract one date from another, yielding the number of days between the two dates. The following example subtracts July 25, 2007, from August 2, 2007:
    SELECT TO_DATE('02-AUG-2007') - TO_DATE('25-JUL-2007')
    FROM dual;
    TO_DATE('02-AUG-2007')-TO_DATE('25-JUL-2007')
    ---------------------------------------------
    8
    

    NOTE:

    TO_DATE() is a function that converts a string to a date.

    SELECT 10 * 12 / 3 – 1
    FROM dual;
    10*12/3-1
    ----------
    39
    
    SELECT TO_DATE('02-AUG-2007') - 3
    FROM dual;
    TO_DATE('
    ---------
    30-JUL-07
    

      

    select 1 from dual where null=null; 
    1
    select 1 from dual where null='';
    1
    select 1 from dual where ''='';
    1
    
    ___________________________________
    
    select 1 from dual where null is null;  
    1
    ---
    1
    select 1 from dual where nvl(null,0)=nvl(null,0); 
    1
    ---
    1
    select user from dual; 
    USER
    ---
    FAIRPT
    select sysdate from dual; 
    SYSDATE
    ---
    24-NOV-15
    

      

  • 相关阅读:
    IDA*算法
    智能指针
    C51模拟I2C,音乐播放(记忆)
    类与对象解剖(虚函数)
    MFC类层次结构
    平面几何
    IDAstar搜索
    MFC程序初始化过程
    放苹果 分治法
    【读后感】编程珠玑 第九章 代码调优
  • 原文地址:https://www.cnblogs.com/mylinux/p/4991372.html
Copyright © 2011-2022 走看看