Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
954 views
in Technique[技术] by (71.8m points)

postgresql - Postgres sql insert query syntax error from phpPgAdmin

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")

The error I get is the following:

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

enter image description here

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:

enter image description here

updated 1

Similar question - INSERT INTO PostgreSQL

updated 2

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...