Closed
Description
Language Usage / DML & SQL / General
Never use SELECT * in a (sub-)query that selects directly from tables or views
from SonarQube
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
myvar CHAR;
BEGIN
SELECT * INTO myvar FROM DUAL;
END;
Compliant Solution
DECLARE
myvar CHAR;
BEGIN
SELECT dummy INTO myvar FROM DUAL;
END;
Exceptions
Wrapper queries using ROWNUM are ignored.
SELECT *
FROM ( SELECT fname, lname, deptId
FROM employee
ORDER BY salary
)
WHERE rownum <= 10