Postgres sql insert query syntax error from phpPgAdmin

后端 未结 3 996
伪装坚强ぢ
伪装坚强ぢ 2020-11-27 08:19

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


        
相关标签:
3条回答
  • 2020-11-27 08:32

    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

    0 讨论(0)
  • 2020-11-27 08:38

    The phpPgAdmin UI provides two links for running SQL - one in the main body of the page, and one in the menu bar at the top of the page.

    The one in the main body of the page will throw the error you're seeing if you run a data definition statement like CREATE TABLE.

    However, the one in the menu bar will run data definition queries with no problem.

    In short:

    screen

    0 讨论(0)
  • 2020-11-27 08:53

    you could try this as well

    INSERT INTO "user" ("username", "password_hash", "first_name", "last_name") VALUES( 'Foo',MD5('54321'),'Foo','Bar' );

    0 讨论(0)
提交回复
热议问题