insert into table (col_identifier, period) values ('Proceeds', 2016)
I would like to insert for period 2016 to 2080. Is it possible to insert this range in one line statement, or do I have to write it out for each period?
Use INSERT INTO ... SELECT
with a query that generates rows:
INSERT INTO table_name ( col_identifier, period )
SELECT 'Proceeds', 2015 + LEVEL
FROM DUAL
CONNECT BY 2015 + LEVEL <= 2080;
or
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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.