MySQL Forums
Forum List  »  General

Re: INSERT, UPDATE, REPLACE INTO alternate key
Posted by: M K
Date: December 19, 2012 04:35PM

Peter,

Thanks. However, could you help with my original questions?

Q1: Is there a way to supply a separate field to be used as a "key" for a REPLACE INTO or a INSERT INTO command, such as (faux code):

REPLACE INTO mytable (select * from temporary_table) FORCE KEY TO BE id_column;

or

INSERT INTO mytable
SELECT * FROM temporary_table
FORCE KEY TO BE mytable.MYFIELD
ON DUPLICATE KEY UPDATE myfield = temptable.myfield;


Second question is whether modifying the PRIMARY KEY of an existing database, and setting it back after an operation, if that would result in any loss of data, unique identifiers, etc.


Third question is whether concepts that come up in my research such as "alternate key", "foreign key", etc would help in my situation. The situation is that my command does not work because the database table uses the wrong field for a PRIMARY KEY.

Options: ReplyQuote


Subject
Written By
Posted
Re: INSERT, UPDATE, REPLACE INTO alternate key
M K
December 19, 2012 04:35PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.