What Should We Know About Changing A Primary Key?

sqlinsix(58)
Published in
#data
Words
386
Reading
2 min
Listen
Play
6y

What happens when we run into the situation where we want or need to change a primary key? Check out the solution in the video T-SQL: Changing A Primary Key - What We Should Consider. As we can see, we discuss the problem involving changing a primary key on a table. This sometimes occurs in both ETL and replication contexts along with other architectural contexts where we see a shift in design.

Some points that we consider:

  • What should we know on the architecture side?
  • Why are we considering this?
  • What did we miss about scale or design?
Keep in mind that we want to know the answers to this.

Automating ETL
For mastering data transformation from one form to another form, check out the highest-rated Automating ETL course on Udemy. For a coupon to the course, check out the trailer video on the channel SQL In Six Minutes.

This requires significant thought because changing a primary key will have effects - possibly significant effects as far as dependencies. It also means that we didn't consider our design initially and we want to be sure that we aren't reacting again and overlooking something else that may later mean a change.

One regular point I like to remind my audience, especially as of recent: we can often solve the same problem with a variety of techniques. While we look at one or two ways to solve the problem, these aren't the only ways we can approach this problem. The most appropriate solution to a problem is one in which you can troubleshoot quickly in the future and one in which you understand. Be careful about applying solutions that solve a problem, but introduce new problems in the future.

A great re-occuring example of this is my discussion on alerting best practices. There are a variety of alerts everywhere for everything in today's development environments, but many of these alerts cause more issues than they solve (one of which is creating a distraction). Be careful about "easy" solutions which introduce bigger problems. Know your environment and where to apply the best solution. Of course, all these being written, it is helpful to learn new techniques to solve problems because they may be useful in the future.

SQL In Six Minutes | Automating ETL | T-SQL In 2 Hours | Consumer Guide To Digital Security

What Should We Know About Changing A Primary Key? | Ecency