dual表是和Oracle数据字典一起创建的。它实际上只包含dummy这一个column,并且只有一条记录,这条记录的值是X。
1SQL>desc dual;
2Name Type Nullable Default Comments
3----- ----------- -------- ------- --------
4DUMMYVARCHAR2(1) Y
5
6SQL>select*from dual;
7
8DUMMY
9-----
10X
2Name Type Nullable Default Comments
3----- ----------- -------- ------- --------
4DUMMYVARCHAR2(1) Y
5
6SQL>select*from dual;
7
8DUMMY
9-----
10X
dual表的owner是SYS,但所有用户都可以访问它。Although it is possible to delete the one record, or insert additional records, one really should not do that!.
Next,我们来看一下dual表都有哪些作用。
--Query current date/time
SQL>select sysdate from dual;
SYSDATE
-----------
2/06/20113
SQL>select to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss') systime from dual;
SYSTIME
-------------------
2011-06-0203:58:47
--Used as a calculator
SQL>select1+2from dual;
1+2
----------
3
--Query the current user
SQL>selectuserfrom dual;
USER
------------------------------
OPS$GLOBAL
--Query sequence
SQL>create sequence seq increment by2 start with1;
Sequence created
SQL>select seq.nextval from dual;
NEXTVAL
----------
1
SQL>select seq.nextval from dual;
NEXTVAL
----------
3
SQL>select seq.currval from dual;
CURRVAL
----------
3