PostgreSQL insert query
Solution 1
Try single quotes (e.g. '2011-11-09')
Solution 2
PostgreSQL has a "datetime" type: timestamp
. Read the manual here.
The double-qutes ""
are used for identifiers if you want them as is. It's best you never have to use them as @wildplasser advised.
String literals are enclosed in single quotes ''
.
Start by reading the chapter Lexical Structure. It is very informative. :)
Solution 3
Try it rewrite in this way:
INSERT INTO log (ip,country,region,city,"postalCode",taken,date) VALUES ('24.24.24.24','US','NY','Binghamton','11111',1,'2011-11-09');
When you are using mixed case in the name of column, or reserved words (such as "column", "row" etc.), you have to use double quotes, instead of values, where you have to use a single ones, as you can see in the example.
Comments
-
Expert wanna be over 3 years
I try to insert a single line to log table, but it throws an error message . ><
The
log
table structure is like this:no integer NOT NULL nextval('log_no_seq'::regclass) ip character varying(50) country character varying(10) region character varying(10) city character varying(50) postalCode character varying(10) taken numeric date date
and my query:
INSERT INTO log (ip,country,region,city,postalCode,taken,date) VALUES ("24.24.24.24","US","NY","Binghamton","11111",1,"2011-11-09")
=> ERROR: column "postalcode" of relation "log" does not exist
second try query : (without postalcode)
INSERT INTO log (ip,country,region,city,taken,date) VALUES ("24.24.24.24","US","NY","11111",1,"2011-11-09")
=> ERROR: column "24.24.24.24" does not exist
I don't know what I did wrong...
And PostgreSQL does not have datetime type? (2011-11-09 11:00:10)