BREAK

BREAK is a command in SQL used to exit a loop before the loop has looped through all its conditions or rows. It abruptly stops the execution of the loop, providing control to the statement that directly follows the loop.

Example

BREAK ON DEPARTMENT_ID;
SELECT * FROM EMPLOYEES
ORDER BY DEPARTMENT_ID;

Output

DEPARTMENT_ID EMPLOYEE_ID FIRST_NAME LAST_NAME
------------- ----------- ---------- ----------
10 200 Jennifer Whalen
20 201 Michael Hartstein
202 Pat Fowler
30 114 Den Raphaely
115 Alexander Khoo
116 Shelli Baida
117 Sigal Tobias
118 Guy Himuro
119 Karen Colmenares

Explanation

BREAK command in Oracle SQL is used to suppress the duplicate values of a certain column in the output. It is usually used together with the ORDER BY clause. In the example provided, BREAK ON DEPARTMENT_ID suppresses subsequent display of the DEPARTMENT_ID when the value is the same as the DEPARTMENT_ID value of the previous row.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.