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. 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 是一个实际存在的虚表,任何用户均可读取,存在的目的是作为 from的源。
1 |
|
首先搞清楚DUAL是什么OBJECT :
1 | select owner, object_name , object_type from dba_objects where object_name like '%DUAL%'; |
原来DUAL是属于SYS schema的一个表,然后以PUBLIC SYNONYM的方式供其他数据库USER使用.
再看看它的结构:
DUAL表可以执行插入、更新、删除操作,也执行drop操作。但是不要去执行drop表的操作,否则会使系统不能用会报Database startup crashes with ORA-1092错误。
如果DUAL表被“不幸”删除后的恢复:
用sys用户登陆。
创建DUAL表。
授予公众SELECT权限(SQL如上述,但不要给UPDATE,INSERT,DELETE权限)。
向DUAL表插入一条记录(仅此一条): insert into dual values(‘’X’’);
提交修改。
具体操作:
用sys用户登陆。
1 | SQL> create pfile=’d:/pfile.bak’ from spfile |