Postgres error updating column data

点点圈 提交于 2020-05-17 05:43:06

问题


Trying to run a update script on a table, but getting an error:

ERROR: column "ok" does not exist LINE 2: SET first_name="ok", last_name="pk", email="ooo", phone="...

CREATE TABLE employee (
   employee_id      SERIAL PRIMARY KEY,
   first_name       varchar(255)                NOT NULL,
   last_name        varchar(255)                NOT NULL,
   email            varchar(255)                NOT NULL,
   phone            varchar(255)
);


INSERT INTO employee(
            first_name, last_name, email, phone)
    VALUES ('Kyle', 'Belanger', 'kbelanger@ok.com', '(240) 298-4664');


UPDATE "employee"
   SET first_name="ok", last_name="pk", email="ooo", phone="000"
 WHERE employee_id = 1;

回答1:


There is no need to wrap table name in double quote "employee", and use single quotes for column values

UPDATE employee   
   SET first_name='ok', last_name='pk', email='ooo', phone='000'
 WHERE employee_id = 1;

See Working Example




回答2:


Try below sql:

 UPDATE employee
   SET first_name='ok', last_name='pk', email='ooo', phone='000'
 WHERE employee_id = 1;

Table name was wrapped in double quotes which is not allowed.



来源:https://stackoverflow.com/questions/30764963/postgres-error-updating-column-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!