Oracle/Oracle SQL Developer Flashcards
Selecting from the DUAL Table
https://docs.oracle.com/cd/B19306_01/server.102/b14200/queries009.htm
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. Please refer to “SQL Functions” for many examples of selecting a constant value from DUAL.
creating a variable and assigning value with dual
declare startdate number; begin select 20110501 into startdate from dual; end;
creating a variable and assigning value
DEFINE StartDate = TO_DATE(‘2016-06-21’);
DEFINE EndDate = TO_DATE(‘2016-06-30’);
SELECT * FROM MyTable WHERE DateField BETWEEN &StartDate and &EndDate;