Re: Change column datatype from INT to BIGINT

Поиск
Список
Период
Сортировка
От Michael Guissine
Тема Re: Change column datatype from INT to BIGINT
Дата
Msg-id CACxDrAnUg9gCrrbZqopyA3QucNrwMyB7caLNDTE-u17J5WxTDw@mail.gmail.com
обсуждение исходный текст
Ответ на Change column datatype from INT to BIGINT  (srinivasan s <srinioracledba7@gmail.com>)
Список pgsql-admin
I guess it depends on how far you are from the column reaching its max value and if it's also a primary key on the table or not.

Assuming you still have enough time for this conversion:

If column is NOT primary key:

1. Ensure you have enough space in your database
2. Add a new bigint column
3. Add a trigger to populate a new column from the original as the changes come in
4. Back populate new column for the existing records
5. Take a small downtime window:
     a) rename old column to something like column_old
     b) rename new column as old column
6. validate and drop old column

If the column is also a Primary key, there are few more steps required before you can swap

~ Michael

On Mon, Mar 11, 2024 at 1:12 PM srinivasan s <srinioracledba7@gmail.com> wrote:
Hi everyone 

Hope you’re doing good!

We need to change the data type of one of the columns in the large table from INT to BIGINT because it reaches the maximum integer value. What is the best way to do this conversion from INT to BIGINT with no downtime or very minimal impact, I look forward to receiving help from the experts here. Thanks

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

Предыдущее
От: srinivasan s
Дата:
Сообщение: Change column datatype from INT to BIGINT
Следующее
От: kumar victor
Дата:
Сообщение: Re: Advanced DBA Training