Quantcast
Channel: postgreSQL concurrently change column type from int to bigint - Stack Overflow
Browsing all 5 articles
Browse latest View live

Answer by Radek Postołowicz for postgreSQL concurrently change column type...

If you don't have foreign keys pointing your id you could add new column, fill it, drop old one and rename new to old: alter table my_table add column new_id bigint; begin; update my_table set new_id =...

View Article



postgreSQL concurrently change column type from int to bigint

I have a pretty big table (around 1 billion rows), and I need to update the id type from SERIAL to BIGSERIAL; guess why?:). Basically this could be done with this command: execute "ALTER TABLE...

View Article

Answer by xhafan for postgreSQL concurrently change column type from int to...

I tried @radek-postołowicz solution, but it failed for me as I needed to set the new_id column as not null, and that locks the table for a long time.My solution:Select records from the old table, and...

View Article

Answer by Ethan Pailes for postgreSQL concurrently change column type from...

Radek's solution looks great. I would add a comment if I had the reputation for it, but I just want to mention that if you are doing this you'll likely want to widen the sequence for the primary key as...

View Article

Answer by brauliobo for postgreSQL concurrently change column type from int...

Merging both @radek-postołowicz and @ethan-pailes answers for a full concurrent solution, with some tweaks we get:alter table my_table add column new_id bigint;-- new records fillingCREATE FUNCTION...

View Article

Browsing all 5 articles
Browse latest View live




Latest Images