Re: interval data type

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Re: interval data type
Дата
Msg-id 7592ec6a-b3d2-e376-ff16-af03120fcbc8@gmx.net
обсуждение исходный текст
Ответ на interval data type  ("James B. Byrne" <byrnejb@harte-lyne.ca>)
Список pgsql-general
James B. Byrne schrieb am 21.01.2021 um 22:22:
> What is the difference between interval(3)[] and simply interval(3)?  Where in
> the documentation is the [] syntax discussed?

The [] denotes an array of intervals.

So in a column defined as interval[] you can store multiple intervals, just
like in an array of text (text[]), where you can store multiple strings.

This is discussed in the chapter about arrays:

    https://www.postgresql.org/docs/current/arrays.html

> Also I do not understand under what circumstance one would use the interval
> type in place of a simple integer.

What would that integer represent? Seconds? Minutes? Hours? Fractional days?

Using an interval makes things a lot easier, because you can store any "duration"
in it without the need to know what the unit is that is stored in the column.

Also timestamp values and intervals go well together, but not timestamps and integers

You can add an interval to a timestamp and the result is a new timestamp.
If you stored the "duration" as integer, you would first need to convert the
integer to an interval.





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

Предыдущее
От: Peter Geoghegan
Дата:
Сообщение: Re: autovacuum verbose?
Следующее
От: Christophe Pettus
Дата:
Сообщение: Re: interval data type