来自phpPgAdmin的Postgres SQL插入查询语法错误 [英] Postgres sql insert query syntax error from phpPgAdmin

查看:106
本文介绍了来自phpPgAdmin的Postgres SQL插入查询语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试执行标准的插入查询,但这不起作用.

Trying to execute a standard insert query, but it doesn't work.

INSERT INTO users (vk_id, eu_name, eu_society, eu_notes, eu_want_team)
VALUES ("123123133","Eu name","Eu society","Eu notes","true")

我得到的错误如下:

ERROR:  syntax error at or near "INTO" LINE 1: SELECT COUNT(*) AS
 total FROM (INSERT INTO users (vk_id, eu_...

是什么原因导致此错误?

What is causing this error?

推荐答案

我已安装phpPgAdmin尝试重现您的错误.尝试创建测试表时,我马上就知道了:

I've installed phpPgAdmin to try to reproduce your error. I got it right away when tried to create a test table:

所以看起来phpPgAdmin将查询包装到select count(*) as total from (...)中.我发现只有在查询页面上的复选框分页结果" 设置为on时才会发生这种情况(显然phpPgAdmin试图计算它将获得多少行,然后逐页显示).取消选中它,您的查询将正常运行:

So looks like phpPgAdmin wraping your query into select count(*) as total from (...). I've found that it happens only when checkbox "Paginate results" on query page is set to on (obviously phpPgAdmin trying to count how many rows it will get and then show it page by page). Uncheck it and your query will work fine:

更新了1

类似的问题-插入PostgreSQL

更新了2

正如@akshay在评论中提到的那样,您还可能在命令行中运行查询时遇到类似的错误,请参阅解释的情况并在此处回答-

As @akshay mentioned in comments, you also could get similar error running the queries through the command line, see explained situation and answer here - PostgreSQL disable more output

这篇关于来自phpPgAdmin的Postgres SQL插入查询语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆