简体   繁体   English

postgres 列“X”不存在

[英]postgres column "X" does not exist

I have this postgrse code:我有这个 postgrse 代码:

CREATE TABLE IF NOT EXISTS config_change_log
(
  id                    serial primary key,
  last_config_version   varchar(255) NOT NULL,
  is_done               Boolean NOT NULL DEFAULT '0',
  change_description     varchar(255),
  timestamp timestamp   default current_timestamp
);

INSERT INTO config_change_log(last_config_version, is_done, change_description )
VALUES("5837-2016-08-24_09-12-22", false, "{ 'key':'value'}");

and I get this error:我得到这个错误:

psql:createConfigChangeLog.sql:11: ERROR:  column "5837-2016-08-24_09-12-22" does not exist
LINE 2: VALUES("5837-2016-08-24_09-12-22", false, "{ 'key':'value'}"...

how can it be?怎么会这样? it's a value not a column.postgr这是一个值而不是 column.postgr

Use single quotes for string constants对字符串常量使用single quotes

INSERT INTO config_change_log(last_config_version, is_done, change_description )
VALUES('5837-2016-08-24_09-12-22', false, '{ ''key'':''value''}');

Also you can escape single quotes in data by doubling them您还可以通过将数据加倍来转义数据中的single quotes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM