Postgres error updating column data

6.4k views Asked by At

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', '[email protected]', '(240) 298-4664');


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

There are 2 answers

0
HaveNoDisplayName On BEST ANSWER

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

4
Explorer On

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.