Note that there are some explanatory texts on larger screens.

plurals
  1. POAltering candidate key in SQL Server 2005
    primarykey
    data
    text
    <p>I have a rather interesting task ahead of me and I want to make sure I am thinking it out correct - </p> <p>I have a table <code>Part</code> that has its <code>part_id</code> being used as part of the candidate keys of several other tables (<code>A</code>, <code>B</code>, <code>C</code>). I need to drop <code>Part</code> and use <code>Product</code> instead. <code>A</code>, <code>B</code>, <code>C</code> need to have their <code>part_id</code> column (which is of type <code>bigint</code>) replaced with a new column of <code>product_id</code> (which is of datatype <code>int</code>). I need to use the <code>part_id</code> column of the tables to determine what <code>product_id</code> I need to use for each row. </p> <p>Here is what I am thinking is what I need to do (thoughts?):</p> <ol> <li>create the <code>product_id</code> column in each of the tables (<code>A</code>, <code>B</code>, <code>C</code>) </li> <li>set the <code>product_id</code> of each row for each table to the appropriate value </li> <li>drop any constraints/fk/pk I have for the <code>part_id</code> column in <code>A</code>, <code>B</code>, <code>C</code></li> <li>drop the <code>part_id</code> from those tables completely</li> <li>recreate the constraints/fk/pk I dropped earlier, only have <code>product_id</code> be part of them instead</li> <li>drop the <code>Part</code> table completely</li> </ol> <p>Can anyone see any potential issues that I may be neglecting?</p> <p>Thanks!</p> <p>Additional Info: Tables <strong>A, B</strong>, and <strong>C</strong> each have LOTS of data, so if there is more performant way, I am all ears.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload