×

Loading...

Topic

This topic has been archived. It cannot be replied.
  • 工作学习 / IT技术讨论 / In Oracle, What is DUAL? what info can I get from DUAL?
    • whatis.com
    • dual is a dummy table. you can get sysdate,or a sequence from dual.
      you can get anything that is not in a real table. for example:
      select 2+1 from dual;
      how ever,this statement is not useful.
      • I think it could be useful when you are lazy and want SQL to do some calculation for you: "select some_date + 280 days from dual". Right?
        • yes,it's true. u r smart.
        • select to_date('my departure day','yyyymmdd') + 182 from dual; 算什么时候必须再入境,就更有用了。
    • SELECT sysdate FROM dual;
    • What if I deleted the dual accident?
      • you can not delete it!
        • It can be deleted. (delete from dual; note: dual belongs to sys) But why you delete it.
          • Just to do a test for fun. Is it posible for me to recover it?
            • For fun, you can try to insert another row into this table, hehe.
              • egg will break if it contains more than one row, read this...
                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 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 command. Because DUAL has only one row, the constant is only returned once. Alternatively, you can select a constant, pseudocolumn, or expression from any table.

                Note that DUAL can have more than one record. The kernel knows that DUAL is a single row single column table, but the PLSQL engine does not. This is important because things will break if it contains more than one. If you are running Oracle Applications, some patches dump multiple rows into the DUAL table. That is why the ADADMIN utility gives you options to check the dual table. We highly recommend doing this!

                --from ora tips
              • hehe! Try it before you leave your office and be prepared to explain the failed night jobs to your manager next morning.
              • Wow! It's so easy. I just inserted that record. Thanks, glad to know all you database guys here. Don't worry for me. I never do any test on the database other than the one only for me to play with.
        • It can't be droped.
    • 各位DATABASE大侠,有Oracle方面的工作机会别忘了我!