接触数据库过程中会遇见select sysdate from dual 这样的情况
然后去 desc dual 表会
SQL> desc dual
Name Null? Type
----------------------------------------- -------- ----------------------------
DUMMY VARCHAR2(1)
查看官方文档给出的解释为
The DUAL table
The table named DUAL is a small table in the data dictionary that Oracle and
user-written programs can reference to guarantee a known result. This table has one column called DUMMY and one row containing the value X .
这里我们会有这样的疑问:既然是dummy 大小为一列 那么我们在select sysdate from dual 的时候 出来的结果可不是一个字符如下:
SQL> select sysdate from dual;
SYSDATE
---------
20-MAR-13
而我们做个实验 创建一张表 定义一个字段 大小为varchar2(1)
然后去insert into几个字符。 会出现 value too large for column 的ORA-12899 错误。
这是为什么呢。
回到定义: dual 是一张转换表 (特殊表)它是一个数据字典。
下面是TOM 大师的描述。
There is internalized code that makes this happen. Code checks that ensure that a table scan of SYS.DUAL only returns one row. Svrmgrl behaviour is incorrect but this is now an obsolete product.
dual 的内部实现了各种功能且只返回一行。至于怎么实现的 ORACLE当然不会告知我们。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26764973/viewspace-756621/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26764973/viewspace-756621/