DUAL 表

接触数据库过程中会遇见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/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值