Inserting values into a table not working
You must use single quotes for literal string values. Double quoting is interpreted as being an identifier, in this case a column name, which causes the error.
insert into users (id,name,gender,city,age,company)
values (1,'omkar','male','cuttack',24,'tcs');
cannot get simple PostgreSQL insert to work
Use 'auto dealer'
instead. PostgreSQL interprets "
as being quotes for identifiers, '
as being quotes for strings.
Also:
If this is a new project, just don't use mixed case tables; it is a
source of frustration later. Instead of being able to use any case in
your SQL statements, you must both quote the identifier name and get
the case correct.There is no need to specify
id
/DEFAULT
, you're
asking it to do what it would have done already. I haven't met a DBMS
that requires you to includecolumnName
/DEFAULT
if you want it to
put the default value in the column, so I don't think this extra KV
pair is going to make what is happening clearer to anyone reading
your code later.
INSERT COMMAND :: ERROR: column value does not exist
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
Related Topics
Group by SQL Query on Comma Joined Column
Can Linq to SQL Query an Xml Field Db-Serverside
Create View Must Be the Only Statement in the Batch
Exists/Not Exists: 'Select 1' VS 'Select Field'
Update a Single Row with T-Sql
The Object Name Contains More Than the Maximum Number of Prefixes. the Maximum Is 3
Select Columns with Particular Column Names in Postgresql
Re-Use Aliased Field in SQL Select Statement
How to Call a User Defined Function to Use with Select, Group By, Order By
What Are Some of Your Most Useful Database Standards
Using a Single Row Configuration Table in SQL Server Database. Bad Idea
How to Implement Logging and Error Reporting in SQL Stored Procedures