首页 > 数据库技术 > 详细

sql: DUAL

时间:2015-11-24 14:40:16      阅读:523      评论:0      收藏:0      [点我收藏+]

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

  

 

sql: DUAL

原文:http://www.cnblogs.com/mylinux/p/4991372.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!