我正在 SQL Developer 中执行以下查询。
SELECT * FROM Person where person_name='rahul' order by created_time desc limit 10;
当我执行它时,SQL Developer 给出以下错误。
ORA-00933: SQL command not properly ended
00933. 00000 - "SQL command not properly ended"
*Cause:
*Action:
我使用以下链接作为参考。
https://www.techonthenet.com/sql/select_limit.php
我已经尝试过了
SELECT * FROM Person where person_name='rahul' order by created_time desc OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY;
ORA-00933: SQL command not properly ended
00933. 00000 - "SQL command not properly ended"
*Cause:
*Action:
Error at Line: 1 Column: 75
请注意,OFFSET 不被视为关键字。
是的,这会导致 Oracle 没有或不支持
limit
子句,因此您会收到 ORA-00933
错误。相反,使用 FETCH .. OFFSET
构造如
SELECT * FROM Person
where person_name='rahul'
order by created_time desc
OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;
我已使用以下查询解决了该问题。
SELECT * FROM Person where person_name='rahul' and rownum between 1 and 2 order by created_time desc;
如果你得到了
ORA-00933: SQL command not properly ended
00933. 00000 - "SQL command not properly ended"
*Cause:
*Action:
这可能是因为您没有运行 Oracle 12。在这种情况下,有一些解决方法,所有方法都涉及子查询,而且大多数都很草率。我用过
select * from
( select column_name, ROWNUM rnum from
( select * from table_name)
where ROWNUM <= max_row )
where rnum >= min_row order by column_name;