The following statements are frequently seen in projects:
Select seq_project.nextval from dual
Used to obtain the sequence value. But I didn't create the dual table. who created this table? What is it mainly used?
Some of the explanations I have found are as follows:
Dual is a table automatically created by Oracle and the data dictionary. It has only one column: dummy, whose data type is varchar2 (1 ).
There is only one row of data in dual: 'X '.
Dual belongs to SYS mode, but all users can access it using the dual name. This table is often used to calculate the constant expression and pseudo column equivalence using select, because it only returns one row of data, while multiple data rows may be returned when other tables are used.
1. view the current user. You can execute the following statement in SQL plus.
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 the host name
Select sys_context ('userenv', 'language') from dual; -- get the current locale
Select dbms_random.random from dual; -- obtain a random number
3. Obtain the next or current value of the sequence. Use the following statement.
Select your_sequence.nextval from dual; -- Obtain the next value of the sequence your_sequence
Select your_sequence.currval from dual; -- get the current value of the sequence your_sequence
4. It can be used as a calculator.
Select 7*9 from dual;