ddl
CREATE TYPE url AS (
url varchar,
status int4);
CREATE TABLE public.tiantang_page (
href varchar NOT NULL,
status int4 NOT NULL,
description varchar NOT NULL,
urls url[] NULL,
urltest url NULL
);
sql
INSERT INTO public.tiantang_page
(href, status, description, urls, urltest)
VALUES('', 0, '', array[row('test',0)], row('test',0));
错误
SQL Error [42804]: ERROR: column "urls" is of type url[] but expression is of type record[]
Hint: You will need to rewrite or cast the expression.
Position: 97
答案 0 :(得分:2)
根据错误消息,您需要使用url
投射回复合::
类型
INSERT INTO public.tiantang_page
(href, status, description, urls, urltest)
VALUES('', 0, '', array[row('test',0)::url], row('test',0)::url);