DUAL is a table automatically created by Oracle Database along with the data dictionary. DUAL is in the schema of the user SYS but is accessible by the name DUAL to all users.
It has one column, DUMMY, defined to be VARCHAR2(1), and contains one row with a value X.
Dual在Oracle中是一个虚拟表,它只有一个类型为VARCHAR2的子段,即DUMMY,值为X。
DU
—–
X
Selecting from the DUAL table is useful for computing a constant expression with the SELECT statement. Because DUAL has only one row, the constant is returned only once. Alternatively, you can select a constant, pseudocolumn, or expression from any table, but the value will be returned as many times as there are rows in the table. Please refer to “SQL Functions” for many examples of selecting a constant value from DUAL.
此外,DUAL表还有许多其他的用途:
1. 查看当前用户
USER
——
SCOTT
2. 调用系统函数,比如日期、随机获取数字等
3. 进行数学运算
4. 查看序列值
注:序列建立后,sequence.currval
一定要在next.currval
后面执行;如果序列建立后就获取sequence.currval
会报错:sequence ABC.CURRVAL is not yet defined in this session
。
文中引用出自:https://docs.oracle.com/cd/B19306_01/server.102/b14200/queries009.htm