Skip to content
Advertisement

How to change id column type already registered in the database

I’m trying to change my Id column type from int to bigInt because the records are too big and I’m getting an error if I try to store more records but I’m not sure if it’s safe to just alter the table like this:

 alter table the_table
     alter the_column type bigint;

I’m using Java Springboot to create the entities and Hibernate for persistence. What’s the best way to solve this issue in a safe way since there are very important records inside the DB?

Advertisement

Answer

Why can’t you just do this?

ALTER TABLE tableName ALTER COLUMN ID bigint

I guess try it in a test environment first but this always works for me

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement