CREATE TABLE people(
name_ varchar(50) NOT NULL,
count int NOT NULL DEFAULT 0
)
CREATE TABLE person_added(
date_ date NOT NULL,
all_people_ people[],
all_people_count int NOT NULL
)
CREATE TABLE all_people_array_table(
id SERIAL,
people_array person_added[]
)
INSERT INTO all_people_array_table(people_array) (SELECT ARRAY[CURRENT_DATE, ARRAY[('Jack',3)::people, ('John',6)::people], 1000] )
我收到此错误;
错误:ARRAY类型日期和情感[]无法匹配
什么是正确的插入语句?
答案 0 :(得分:0)
这对我有用:
insert into all_people_array_table(people_array)
select array[
(current_date,
array[
('Jack',3)::people,
('John',6)::people
], 1)::person_added
];