2

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;
1
  • 1
    "ok" is a column name, not a string literal. Please read the manual: postgresql.org/docs/current/static/… Commented Jun 11, 2015 at 5:55

2 Answers 2

5

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

Sign up to request clarification or add additional context in comments.

Comments

1

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.

4 Comments

even column values also need single quote only, not double quotes
I am not sure about it but the above query worked in sql fiddle.
see this , SQL fiddle for your query sqlfiddle.com/#!15/93c2a/10. Share your fiddle which is working?
I changed it. I did ran it with single quote in sql fiddle. Thanks for pointing it out. (up-vote for your suggestion :) )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.