Re: COPY and custom datestyles. Or some other technique?

Поиск
Список
Период
Сортировка
От Ron
Тема Re: COPY and custom datestyles. Or some other technique?
Дата
Msg-id 9c9380da-dcf9-7159-a59e-ecc50d34b30c@gmail.com
обсуждение исходный текст
Ответ на Re: COPY and custom datestyles. Or some other technique?  ("David G. Johnston" <david.g.johnston@gmail.com>)
Ответы Re: COPY and custom datestyles. Or some other technique?  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-general
On 3/29/23 21:06, David G. Johnston wrote:
On Wed, Mar 29, 2023 at 6:51 PM Ron <ronljohnsonjr@gmail.com> wrote:
It would be really helpful to be able to reposition columns in tables.  That
way, one could:
add the new TIMESTAMP column,
populate it using to_timestamp(),
drop the text column,
reposition the TIMESTAMP column to where it "should" be.


If that would give you what you need then just define the column as text initially, load the data, then do an ALTER COLUMN ... ALTER TYPE to change the column type to timestamptz in place, with the conversion done via USING.

David J.


Something like this?

ALTER TABLE foo
    ALTER COLUMN update_ts TIMESTAMP WITHOUT TIME ZONE
        USING to_timestamp(update_ts, 'YYYYMMDDHH24miSSMS');

That would definitely minimize the possibility of errors.

--
Born in Arizona, moved to Babylonia.

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

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: COPY and custom datestyles. Or some other technique?
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: COPY and custom datestyles. Or some other technique?