I'm using postgresql and I'm trying to insert data into a table users
. When I do that using
INSERT INTO users (user_name, name, password,email)
VALUES ("user2", "first last", "password1", "user2@gmail.com" );
I get the following error:
ERROR: column "user2" does not exist
This is how the table looks like:
Table "public.users"
Column | Type | Modifiers
user_name | character varying(50) |
name | character varying(50) |
password | character varying(50) |
email | character varying(100) |
user_id | integer | not null default nextval('users_user_id_seq'::regclass)
Indexes:
"users_pkey" PRIMARY KEY, btree (user_id)
I was able to insert a row, but it is not working now.
Character constants need single quotes.
Use: INSERT INTO users(user_name, name, password,email) VALUES ('user2','first last','password1', 'user2@gmail.com' );
See the manual: postgresql.org/docs/current/static/…
Note: After I encountered the same problem and almost missed the answer that exists in this page (at the comments section), thanks to @a-horse-with-no-name - I've posted this answer