Difficulty: Easy
Correct Answer: Incorrect
Explanation:
Introduction / Context: Standard relational theory treats base tables and views as unordered sets of rows. Sorting is a presentation concern for queries that consume the view. This question asks whether Oracle permits ORDER BY directly in a normal (non-materialized) view's defining SELECT.
Given Data / Assumptions:
Concept / Approach: In Oracle, CREATE VIEW ... AS SELECT ... cannot include ORDER BY unless the ORDER BY is used in a top-N style query where ORDER BY appears in a subquery paired with row-limiting logic (for example, ROWNUM or 12c row-limiting clause). Even then, the outermost defining query of a simple view normally must not end with ORDER BY. Therefore, stating that Oracle allows ORDER BY in the view definition as a general rule is incorrect. Materialized views, however, can have refresh and indexing strategies that affect access paths; still, row order is not guaranteed without ORDER BY in the consuming query.
Step-by-Step Solution:
Attempt CREATE VIEW v AS SELECT * FROM emp ORDER BY ename; → results in error.Place ORDER BY in a subquery for row limiting (advanced cases) → still, the outer view is unordered.Select from the view with ORDER BY to guarantee the desired order.Conclusion: Oracle does not generally allow ORDER BY directly in the view definition.Verification / Alternative check: Test in Oracle: try creating a simple view with ORDER BY and observe the compilation error; then query the view with an ORDER BY and confirm it works as intended.
Why Other Options Are Wrong:
Common Pitfalls: Expecting a view to “remember” sort order; depending on implicit order due to indexes.
Final Answer: Incorrect
Discussion & Comments