INSERT, UPDATE, REPLACE INTO alternate key
Posted by:
M K
Date: December 19, 2012 12:58PM
Hello all,
My primary experience is with website administration and design, and not SQL. So forgive me if this is common knowledge (I can't find an answer after extensive search):
I need to perform some operations on the database such as INSERT INTO, UPDATE, and REPLACE INTO.
However, my CMS database has been poorly designed, and the PRIMARY KEY is a TEXT field of a webpage. They did not use a CONTENT ID, a unique integer as either a PRIMARY or UNIQUE key.
My query must modify the field designated as the PRIMARY and UNIQUE KEY by placing it into a temporary table, modifying its encoding, and overwriting the old table with the new one. Obviously, this changes the field designated to be PRIMARY KEY, and I create duplicates.
Question: can I specify a temporary alternate reference key for the INSERT INTO, UPDATE, or REPLACE INTO operation?
If I cannot do this, can I temporarily switch the column being used as PRIMARY KEY to another field? Will this lead to a loss of data when I switch it back? Is this a safe or a good idea?
Thank you for your time.