[英]Insert data into user-defined type elements of a table in postgresql
I have defined 3 types as follow: 我已经定义了3种类型如下:
CREATE TYPE EventDescriptionType AS ENUM (
'felt report',
'Flinn-Engdahl region',
'local time',
'tectonic summary',
'nearest cities',
'earthquake name',
'region name'
);
CREATE TYPE ResourceReference AS (
"resourceID" varchar(255)
);
CREATE TYPE EventDescription AS (
"text" text,
"type" EventDescriptionType
);
Also I have created a table with elements of above type: 我还创建了一个包含上述类型元素的表:
CREATE TABLE Event (
"Event_id" serial PRIMARY KEY,
"description" EventDescription ARRAY
);
Then, after inserting some data into this table by this command: 然后,通过此命令将一些数据插入此表后:
insert into Event values (1,'{'L','felt report'}');
I got this error: 我收到了这个错误:
ERROR: syntax error at or near "L"
错误:语法错误在“L”或附近
LINE 1: insert into Event values (1,'{'L','felt report'}');第1行:插入事件值(1,'{'L','感觉报告'}');
For Element "dexcription" in the Event table I passed '1' as event_id and 'L' & 'felt report' in an array for for "text" and "type" of EventDescription Type, respectively. 对于事件表中的元素“dexcription”,我将'1'分别作为event_id和'L'和'感觉报告'传递给数组,分别用于“文本”和“类型”的事件描述类型。
Can someone please let me know the correct way to do this? 有人可以告诉我这样做的正确方法吗? Any help would be appreciated.
任何帮助,将不胜感激。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.