Oracle/Oracle SQL Developer Flashcards

1
Q

Selecting from the DUAL Table

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

creating a variable and assigning value with dual

A
declare
 startdate number;
begin
  select 20110501 into startdate from dual;
end;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

creating a variable and assigning value

A

DEFINE StartDate = TO_DATE(‘2016-06-21’);
DEFINE EndDate = TO_DATE(‘2016-06-30’);

SELECT
    *
FROM
    MyTable
WHERE
    DateField BETWEEN &StartDate and &EndDate;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly