插入表格(col_identifier,句点)值('Proceeds',2016)
我想在2016年到2080年期间插入。是否可以在一行声明中插入此范围,或者我是否必须在每个期间写出来?
答案 0 :(得分:3)
将INSERT INTO ... SELECT
与生成行的查询一起使用:
INSERT INTO table_name ( col_identifier, period )
SELECT 'Proceeds', 2015 + LEVEL
FROM DUAL
CONNECT BY 2015 + LEVEL <= 2080;
或
INSERT INTO table_name ( col_identifier, period )
WITH years ( year ) AS (
SELECT 2016 FROM DUAL
UNION ALL
SELECT year + 1 FROM years WHERE year < 2080
)
SELECT 'Proceeds', year
FROM years;