[Feature Request] Support INSERT ... FROM ... TO for date ranges

Поиск
Список
Период
Сортировка
От zkbp712
Тема [Feature Request] Support INSERT ... FROM ... TO for date ranges
Дата
Msg-id lPLMZdNV2uzTI3sEHqF6zdFTOgIpKulgfD7UipFlKJ8TibiIoM3pG75AWnvblj6QgfA_WrJpdUvalXm8v2WfXxrRacGbC2_dWYTPawiEu8s=@proton.me
обсуждение исходный текст
Ответы Re: [Feature Request] Support INSERT ... FROM ... TO for date ranges
Список pgsql-hackers
Dear MySQL/PostgreSQL Development Teams,

My name is T-RegExr (Tyrannosaurus RegExr), and I am a developer working extensively with time-series data such as medication dosages and other daily records.

I would like to propose a feature enhancement to simplify the insertion of multiple rows over a continuous date range.

Problem:
Currently, inserting records for each date in a range requires manually writing multiple INSERT statements or using external 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 to insert one row per date in the range:

(5, 3, '2025-04-01'),
(5, 3, '2025-04-02'),
...
(5, 3, '2025-04-30')

Benefits:

    Reduces verbosity and complexity in SQL scripts

    Improves developer productivity and code readability

    Avoids reliance on external 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)

В списке pgsql-hackers по дате отправления: