ERROR: Column >>?column?<< specified several times
ERROR: Column >>?column?<< specified several times
当我执行以下 UNION ALL 代码将多个表合并为一个实体化视图时,出现错误:column >>?column?<< specified several times。正如您在代码上方所见,我严格保留了原始表格中的顺序。
- 名字
- info1 AS hoehe
- info1 作为艺术
- info1 AS name_alternative
- info2 AS 区域
- info3 AS text_hoehe
- kn AS name_lang
- geoloc
- 符号编号
DROP MATERIALIZED VIEW vt_views.poi_test;
CREATE MATERIALIZED VIEW vt_views.poi_test
TABLESPACE pg_default
AS
SELECT tim_bergname.name,
tim_bergname.info1 AS hoehe,
NULL,
NULL,
tim_bergname.info2 AS region,
NULL,
NULL,
tim_bergname.geoloc,
tim_bergname.symbolnummer
FROM tim_bergname
UNION ALL
SELECT tim_flurname.name,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
tim_flurname.geoloc,
tim_flurname.symbolnummer
FROM tim_flurname
UNION ALL
SELECT tim_haus_huette.name,
NULL,
tim_haus_huette.info1 AS art,
NULL,
tim_haus_huette.info2 AS region,
NULL,
NULL,
tim_haus_huette.geoloc,
tim_haus_huette.symbolnummer
FROM tim_haus_huette
UNION ALL
SELECT tim_museum.name,
NULL,
tim_museum.info1 AS art,
NULL,
NULL,
NULL,
tim_museum.kn AS name_lang,
tim_museum.geoloc,
tim_museum.symbolnummer
FROM tim_museum
UNION ALL
... several other SELECTS (shortened because of Whosebug restrictions)
UNION ALL
SELECT tim_wohnmobilstellplatz.name,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
tim_wohnmobilstellplatz.geoloc,
tim_wohnmobilstellplatz.symbolnummer
FROM tim_wohnmobilstellplatz
WITH DATA;
ALTER TABLE vt_views.poi_test
OWNER TO postgres;
GRANT ALL ON TABLE vt_views.poi TO postgres;
GRANT ALL ON TABLE vt_views.poi TO PUBLIC;
知道这是为什么吗?是因为例如 info1 被使用了三次吗?我无法编辑原始表,因为我们有一批正在填充表。感谢您的帮助!
问题出在第一个查询中,针对 NULL
个条目。您应该命名相应的列:
SELECT tim_bergname.name,
tim_bergname.info1 AS hoehe,
NULL AS mycol1,
NULL AS mycol2,
tim_bergname.info2 AS region,
NULL AS mycol3,
NULL AS mycol4,
tim_bergname.geoloc,
tim_bergname.symbolnummer
FROM tim_bergname
当我执行以下 UNION ALL 代码将多个表合并为一个实体化视图时,出现错误:column >>?column?<< specified several times。正如您在代码上方所见,我严格保留了原始表格中的顺序。
- 名字
- info1 AS hoehe
- info1 作为艺术
- info1 AS name_alternative
- info2 AS 区域
- info3 AS text_hoehe
- kn AS name_lang
- geoloc
- 符号编号
DROP MATERIALIZED VIEW vt_views.poi_test;
CREATE MATERIALIZED VIEW vt_views.poi_test
TABLESPACE pg_default
AS
SELECT tim_bergname.name,
tim_bergname.info1 AS hoehe,
NULL,
NULL,
tim_bergname.info2 AS region,
NULL,
NULL,
tim_bergname.geoloc,
tim_bergname.symbolnummer
FROM tim_bergname
UNION ALL
SELECT tim_flurname.name,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
tim_flurname.geoloc,
tim_flurname.symbolnummer
FROM tim_flurname
UNION ALL
SELECT tim_haus_huette.name,
NULL,
tim_haus_huette.info1 AS art,
NULL,
tim_haus_huette.info2 AS region,
NULL,
NULL,
tim_haus_huette.geoloc,
tim_haus_huette.symbolnummer
FROM tim_haus_huette
UNION ALL
SELECT tim_museum.name,
NULL,
tim_museum.info1 AS art,
NULL,
NULL,
NULL,
tim_museum.kn AS name_lang,
tim_museum.geoloc,
tim_museum.symbolnummer
FROM tim_museum
UNION ALL
... several other SELECTS (shortened because of Whosebug restrictions)
UNION ALL
SELECT tim_wohnmobilstellplatz.name,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
tim_wohnmobilstellplatz.geoloc,
tim_wohnmobilstellplatz.symbolnummer
FROM tim_wohnmobilstellplatz
WITH DATA;
ALTER TABLE vt_views.poi_test
OWNER TO postgres;
GRANT ALL ON TABLE vt_views.poi TO postgres;
GRANT ALL ON TABLE vt_views.poi TO PUBLIC;
知道这是为什么吗?是因为例如 info1 被使用了三次吗?我无法编辑原始表,因为我们有一批正在填充表。感谢您的帮助!
问题出在第一个查询中,针对 NULL
个条目。您应该命名相应的列:
SELECT tim_bergname.name,
tim_bergname.info1 AS hoehe,
NULL AS mycol1,
NULL AS mycol2,
tim_bergname.info2 AS region,
NULL AS mycol3,
NULL AS mycol4,
tim_bergname.geoloc,
tim_bergname.symbolnummer
FROM tim_bergname