数据库
首页 > 数据库> > mysql – 使用LIMIT时SQL命令未正确结束

mysql – 使用LIMIT时SQL命令未正确结束

作者:互联网

我在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没有或支持限制条款,因此您收到ORA-00933错误.相反,使用FETCH .. OFFSET构造就好

SELECT * FROM Person 
where person_name='rahul' 
order by created_time desc 
OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;

StackOverflow中有很多类似的问题.应该尝试搜索相同的.例如:How do I limit the number of rows returned by an Oracle query after ordering?

标签:mysql,oracle-sqldeveloper
来源: https://codeday.me/bug/20190611/1218458.html