INPUT:
SQL> create view emp_tbl as
2 select * from employee_tbl
3 order by name
4 /
OUTPUT:
order by name
*
ERROR at line 3:
ORA-00933: SQL command not properly ended
SQL>
ANALYSIS:
Why is the command not properly ended? You know you can use a / to end an SQL statement. Another fooler. An ORDER BY clause cannot be used in a CREATE VIEW statement. Use a GROUP BY instead. Here the query processor is looking for a terminator (semicolon or forward slash) before the ORDER BY clause because the processor assumes the ORDER BY is not part of the CREATE VIEW statement. Because the terminator is not found before the ORDER BY, this error is returned instead of an error pointing to the ORDER BY.
SQL> create view emp_tbl as
2 select * from employee_tbl
3 order by name
4 /
OUTPUT:
order by name
*
ERROR at line 3:
ORA-00933: SQL command not properly ended
SQL>
ANALYSIS:
Why is the command not properly ended? You know you can use a / to end an SQL statement. Another fooler. An ORDER BY clause cannot be used in a CREATE VIEW statement. Use a GROUP BY instead. Here the query processor is looking for a terminator (semicolon or forward slash) before the ORDER BY clause because the processor assumes the ORDER BY is not part of the CREATE VIEW statement. Because the terminator is not found before the ORDER BY, this error is returned instead of an error pointing to the ORDER BY.
No comments:
Post a Comment