- Notifications
You must be signed in to change notification settings - Fork76
Closed
Description
Language Usage / DML & SQL / General
Never use SELECT * in a (sub-)query that selects directly from tables or views
fromSonarQube
Columns to be read with a "SELECT" statement should be clearly defined
SELECT * should be avoided because it releases control of the returned columns and could therefore lead to errors and potentially to performance issues.
Noncompliant Code Example
DECLARE myvarCHAR;BEGINSELECT* INTO myvarFROM DUAL; END;
Compliant Solution
DECLARE myvarCHAR;BEGINSELECT dummy INTO myvarFROM DUAL;END;
Exceptions
Wrapper queries using ROWNUM are ignored.
SELECT*FROM (SELECT fname, lname, deptIdFROM employeeORDER BY salary )WHERE rownum<=10