[Feature Request] Support INSERT ... FROM ... TO for date ranges
Dear MySQL/PostgreSQL Development Teams,
My nameis T-RegExr (Tyrannosaurus RegExr), and I am a developer working extensively withtime-series data such as medication dosages and other daily records.
I would liketo propose a feature enhancement to simplify the insertion of multiple rowsover a continuous daterange.
Problem:
Currently, inserting records for each datein a range requires manually writing multiple INSERT statements orusingexternal scripts to generate these queries. This approach complicates workflows, reduces readability, and increases the chance of errors.
Proposed Syntax:
INSERT INTO dosage (medication_id, amount, date)
VALUES (5, 3, FROM'2025-04-01'TO'2025-04-30');
This syntax would automatically expand internally toinsert one row per datein the range:
(5, 3, '2025-04-01'),
(5, 3, '2025-04-02'),
...
(5, 3, '2025-04-30')
Benefits:
Reduces verbosity and complexity inSQL scripts
Improves developer productivity and code readability
Avoids reliance onexternal scripting languages for common date-range inserts
Especially useful in domains such as healthcare, education, IoT, and others involving time-series data
Alternative (optional) syntax idea:
INSERT INTO dosage (medication_id, amount, date)
GENERATE RANGE (5, 3, '2025-04-01', '2025-04-30');
Inspiration:
PostgreSQL's generate_series() is a powerful function for generating sequences, but it requires more complex SQL usage and is not directly integrated into the INSERT syntax for repeated values across date ranges.
This proposal aims to bring native, first-class support for inserting repeated values over date intervals, making the language more expressive and the workflow simpler.
Thank you very much for considering this enhancement.
Best regards,T-RegExr (Tyrannosaurus RegExr)
On 2025-Jul-17, zkbp712 wrote:
Alternative (optional) syntax idea:
INSERT INTO dosage (medication_id, amount, date)
GENERATE RANGE (5, 3, '2025-04-01', '2025-04-30');
Here's a simple way to achieve this:
INSERT INTO dosage(medication_id, amount, date)
SELECT 5, 3, g
FROM generate_series(date '2025-04-01', '2025-04-30', '1 day') AS g;
No new features are needed.
--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
"Nunca se desea ardientemente lo que solo se desea por razón" (F. Alexandre)