postgre分页查询报错:ERROR: LIMIT #,# syntax is not supported 建议:Use separate LIMIT and OFFSET clauses

简介: postgre分页查询报错:ERROR: LIMIT #,# syntax is not supported 建议:Use separate LIMIT and OFFSET clauses

问题


使用postgre查询时报错:


ERROR: LIMIT #,# syntax is not supported 建议:Use separate LIMIT and OFFSET clauses

cd93755570c44d8db0ab731138f4f74b.png

分析


错误类型看时PSQLException,说明是postgresql数据库识别的错误

可以看出是因为 sql语句中的"LIMIT #,#"无法识别!

这明显是mysql分页查询语法

select * from table limit #{pageSize}, #{size}
select * from table limit 1, 10

第一次使用postgresql数据库,并不清楚它的sql语句规范


解法


select * from table LIMIT 1 OFFSET 10
//注意该语句的意思是从第10条开始,只查一条数据,这里区分mysql
select * from table LIMIT 10 OFFSET 0
//这个才是从0开始查10条数据
目录
相关文章
|
2月前
|
关系型数据库 MySQL Linux
Packet for query is too large (4467936 > 4194304). You can change this value on the server by setting the max_allowed_packet' variable
【10月更文挑战第15天】解决Packet for query is too large (4467936 > 4194304). You can change this value on the server by setting the max_allowed_packet' variable
104 1
|
7月前
|
SQL 关系型数据库 MySQL
mysql:1153 Got a packet bigger than ‘max_allowed_packet’ bytes的解决方法
mysql:1153 Got a packet bigger than ‘max_allowed_packet’ bytes的解决方法
132 0
|
7月前
|
关系型数据库 MySQL
Packet for query is too large (4,544,730 > 4,194,304). You can change this value on the server by se
Packet for query is too large (4,544,730 > 4,194,304). You can change this value on the server by se
253 0
|
存储 缓存 大数据
Starrocks执行查询报错:Memory of process exceed limit. Used: XXX, Limit: XXX. Mem usage has exceed the limit of BE
Starrocks执行查询报错:Memory of process exceed limit. Used: XXX, Limit: XXX. Mem usage has exceed the limit of BE
|
关系型数据库 MySQL 数据库
mysql下的max_allowed_packet参数设置
mysql下的max_allowed_packet参数设置
1119 0
|
SQL 存储 安全
PageHelper不安全的分页问题,导致ParserException: syntax error, error in :'it 1 LIMIT ? ', expect LIMIT, actual ...
PageHelper不安全的分页问题,导致ParserException: syntax error, error in :'it 1 LIMIT ? ', expect LIMIT, actual ...
191 0
|
SQL 关系型数据库 MySQL
MySQL Case-max_allowed_packet过小是否会截取sql文本?
max_allowed_packet是否会截取sql文本呢
137 1
MySQL Case-max_allowed_packet过小是否会截取sql文本?
|
关系型数据库 MySQL
MySQL - Packet for query is too large (4,544,730 > 4,194,304). You can change this value on the …
MySQL - Packet for query is too large (4,544,730 > 4,194,304). You can change this value on the …
398 0
|
SQL 关系型数据库 MySQL
mysql的 max_allowed_packet 和 max_connections
mysql的 max_allowed_packet 和 max_connections
296 0
|
SQL Oracle 算法
Adaptive and Big Data Scale Parallel Execution in Oracle
在上篇文章中,主要讨论了SQL Server的MPP数仓系统PDW的分布式优化过程,PolarDB的并行优化从中有所借鉴,本篇文章主要看下这篇介绍Oracle并行执行策略的paper,因为在PolarDB的分布式执行策略中,有很多与其有所重叠。
229 0
Adaptive and Big Data Scale Parallel Execution in Oracle