数据库中没有更多的假脱机空间(Teradata)



我是SQL的初学者,我在Teradata上的一个查询遇到了问题。当我运行它时,我得到这个错误:

"数据库中没有更多的假脱机空间";。

根据我在互联网上的研究,问题可能是因为我的查询没有得到足够的优化,只是我不知道如何才能简化它。你能帮帮我吗?

查询错误的来源:

INSERT INTO DESTINATION_TABLE
(YEAR,
QUARTER,
LABEL,
NUMBER,
TIMESTAMP)
VALUES
((SELECT YEAR FROM DATE TABLE),
(SELECT QUARTER DATE TABLE),
'ANY LABEL',
(SELECT COUNT(*)
FROM DATE_TABLE AS TMP
FULL OUTER JOIN TABLE_1 AS T1 ON TMP.PRG_DT = T1.INN_DT
FULL OUTER JOIN TABLE_2 AS T2 ON TMP.PRG_DT = T2.INN_DT
INNER JOIN TABLE_3 AS T3 ON TMP.PRG_DT = T3.INN_DT),
CURRENT_TIMESTAMP);

查询应该做什么:

Year processed = year of DATE_TABLE
Quarter processed = quarter of DATE_TABLE
Label = ‘ANY LABEL’
Number = sum of the number of occurrences of TABLE_1 + number of occurrences of TABLE_2 + number of occurrences of TABLE_3 having for INN_DT the PRG_DT of DATE_TABLE
Timestamp = Current timestamp

第三个组件不需要full join

相反,您似乎想要使用INSERT . . . SELECT:的逻辑

INSERT INTO DESTINATION_TABLE (YEAR, QUARTER, LABEL, NUMBER, TIMESTAMP)
SELECT YEAR, QUARTER, 'ANY LABEL',
( (SELECT COUNT(*)
FROM table1 t1
WHERE dt.PRG_DT = t1.INN_DT
) +
(SELECT COUNT(*)
FROM table2 t2
WHERE dt.PRG_DT = t2.INN_DT
)
),
CURRENT_TIMESTAMP
FROM DATE_TABLE dt;

相关内容

  • 没有找到相关文章

最新更新