问题
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