PostgreSQL插入查询

Exp*_* be 3 postgresql timestamp

我尝试向日志表插入一行,但它会抛出一条错误消息.> <

log表的结构是这样的:

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
Run Code Online (Sandbox Code Playgroud)

和我的查询:

INSERT INTO log (ip,country,region,city,postalCode,taken,date) VALUES 
("24.24.24.24","US","NY","Binghamton","11111",1,"2011-11-09")
Run Code Online (Sandbox Code Playgroud)

=> ERROR: column "postalcode" of relation "log" does not exist

第二次尝试查询:(没有邮政编码)

INSERT INTO log (ip,country,region,city,taken,date) VALUES 
("24.24.24.24","US","NY","11111",1,"2011-11-09")
Run Code Online (Sandbox Code Playgroud)

=> ERROR: column "24.24.24.24" does not exist

我不知道我做错了什么......

PostgreSQL没有日期时间类型?(2011-11-09 11:00:10)

C. *_*yer 10

试试单引号(例如'2011-11-09')

  • 另外:不要使用MixedCase.总有一天它会咬你.另外:date是保留字(typename)不使用它,即使它似乎工作. (2认同)

Erw*_*ter 5

PostgreSQL有一个"日期时间"类型:timestamp.请阅读此处手册.

""如果您希望它们原样,则使用双量程.@wildplasser建议你最好不要使用它们.

字符串文字用单引号括起来''.

首先阅读词汇结构一章.这是非常翔实的.:)