Quick tip: Extending column which is also (part of) primary key
on April 22nd, 2015
Leave a Comment
At work, I got a short task of extending a varchar column in our database from 25 chars length to 50. The task seems easy enough. But, as things usually turn out, it contained a GOTCHA! The column was also a part of primary key on that table. Thus, I started to wonder. Can you resize a column that is part of primary key without recreating primary key itself?
I did some empirical experiment on MSSQL and Oracle RDBMS and came to a conclusion. You actually can just extend the length of a primary key column and primary key will auto-adjust.
Also, in case you are wondering, the same applies to all possible constraints on the table that include said column.
Categories: Tech stuff
Leave a Reply