oracle DUAL table

Dual is a virtual table used to form the syntax rules of select. Oracle guarantees that there is always only one record in the dual. We can do many things with it, as follows:

  1. To view the current user, you can execute the following statement in SQL Plus to select user from dual;

  2. Used to call system functions

  select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;--get the current system time

  select SYS_CONTEXT('USERENV','TERMINAL') from dual;--get hostname

  select SYS_CONTEXT('USERENV','language') from dual;--get the current locale

  select dbms_random.random from dual;--get a random number

  3. To get the next value or current value of the sequence, use the following statement

  select your_sequence.nextval from dual;--get the next value of the sequence your_sequence

  select your_sequence.currval from dual;--get the current value of the sequence your_sequence

  4. Can be used as a calculator select 7*9 from dual;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326247116&siteId=291194637