尝试插入sql转储时,列名处或列名附近出现语法错误
我正在尝试将特定于表的sql转储插入数据库(psql)。 有一个名为“templates”的表,它已经有一些值,正在尝试转储新值。sql文件如下所示尝试插入sql转储时,列名处或列名附近出现语法错误,sql,postgresql,Sql,Postgresql,我正在尝试将特定于表的sql转储插入数据库(psql)。 有一个名为“templates”的表,它已经有一些值,正在尝试转储新值。sql文件如下所示 INSERT INTO templates (id, name, created_at, updated_at, template_path, page_type, container_type, entity_type, entity_id, asset_group_id, data_proxy_id, publisher_id, status,
INSERT INTO templates (id, name, created_at, updated_at, template_path, page_type, container_type, entity_type, entity_id, asset_group_id, data_proxy_id, publisher_id, status, default, image_url_path, sequence) VALUES ('434', 'Full Width Image', '2018-10-25 11:13:35.695256', '2018-11-23 07:26:25.663427', '/templates/full_width_landscape', null, null, null, null, null, null, '655', 'true', 'true', 'template1', 1);
当我尝试通过执行以下操作插入此sql文件时
\i sql file path
我得到以下错误:
ERROR: syntax error at or near "default"
LINE 1: ...et_group_id, data_proxy_id, publisher_id, status, default, i...
有人能告诉我这里出了什么问题吗?您已经将保留字的双引号用作列名
INSERT INTO templates (id, name, created_at, updated_at,
template_path, page_type, container_type,
entity_type, entity_id, asset_group_id,
data_proxy_id, publisher_id, status, "default",
image_url_path, sequence) VALUES ('434', 'Full Width Image', '2018-10-25 11:13:35.695256', '2018-11-23 07:26:25.663427', '/templates/full_width_landscape', null, null, null, null, null, null, '655', 'true', 'true', 'template1', 1);
default
是SQL中的保留字。改用“default”
,即分隔标识符。default
是SQL中的保留字。使用不同的名称,这样就不会与保留字发生冲突。