Testing SELECT Statements Before Implementation

If you are creating a report (using SQL*Plus for example) and the report is rather large, you may want to check spacing, columns, and titles before running the program and wasting a lot of time. A simple way of checking is to add WHERE rownum < 5 to your SQL statement:

SQL> SELECT *
     FROM EMPLOYEE_TBL
     WHERE ROWNUM < 5;

You get the first four rows in the table from which you can check the spelling and spacing to see if it suits you. Otherwise, your report may return hundreds or thousands of rows before you discover a misspelling or incorrect spacing.

Tip

A major part of your job—probably 50%—is to ...

Get Sams Teach Yourself SQL in 21 Days, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.