DUAL is a table automatically created by Oracle along with the data dictionary.
DUAL is in the schema of the user SYS, but is accessible by the name DUAL to all
See Also: table_collection_expression on page 11-96
See Also: Chapter 2, "Basic Elements of Oracle SQL" for
information on hints
Queries and Subqueries
Expressions, Conditions, and Queries 5-29
users. It has one column, DUMMY, defined to be VARCHAR2(1), and contains one row
with a value ’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.
DUAL is in the schema of the user SYS, but is accessible by the name DUAL to all
See Also: table_collection_expression on page 11-96
See Also: Chapter 2, "Basic Elements of Oracle SQL" for
information on hints
Queries and Subqueries
Expressions, Conditions, and Queries 5-29
users. It has one column, DUMMY, defined to be VARCHAR2(1), and contains one row
with a value ’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.
5. Expressions, Conditions, and Queries
Queries and Subqueries
Selecting from the DUAL Table
sysdate
1
'1'
等等时就要用到dual;
select sysdate from dual;
select '1' from dual;
select 1 from dual;
每次使用返回一条记录.
当然 字段要是常量,或者可以计算后得到的结果.
例如:
select 'a','b','c' from dual;
select trunc(sysdate) from dual;
select 1+3+3 from dual;
select trim('test') from dual;
反正只要能够计算得到结果的,或者常量都可以这样使用.
由于ORACLE要保证你SQL语句的完整性,不允许你做形如:select sysdate ,不带FORM的操作。
当你需要做一些取系统时间之类的事情时,方便你返回一条记录,如:select sysdate from dual;
该表为系统中的一个伪表,用来执行一些无表的计算.如查看系统日期等. 对该表可以进行insert ,update,delete 等操作,可以通过select count(*) from dual 来查看表中数据的情况, 如果数据不等于一条的话, 系统中使用了dual的其他的对象将不好用. 如果使用拥有drop 表的权限的用户意见drop该表的,后果不堪设想(具体后果可能是数据库崩溃,我没试过. :) )
dual就是一个一列一行的表。
create sequence seqtest start with 1;
然后试试select seqtest.nextval from dual;