[Pugged] MySql Primary Keys

ciapug@ciapug.org ciapug@ciapug.org
Tue, 14 Jan 2003 00:39:23 -0000


"Dave J. Hala Jr." <dave@58ghz.net> said:

> 
> I'm using  the following statement to move some records from one table
> to another:
> 
> INSERT INTO target_table SELECT * FROM source_table where LHP = "A";
> 
> Works great.  One problem.  Both tables have a primary key that is an
> auto_increment field.    If the source_table has key that is numbered
> 1000, and there is a record with that key value in the target, then
> record doesn't get moved.
> 
> I can resequence the keys doing the following,
> "ALTER TABLE CHECKS DROP id, ADD id int NOT NULL PRIMARY KEY
> AUTO_INCREMENT ", but is there a simple way to renumber the index's in
> the target table starting at a certain value?  
> 

Not sure about that. One thing that I have noticed is that mysql will
let you import from a text file into a table with a PK set without any
special commands - like in MS-SQL, you have to do something like "set
identity-insert off" (don't recall the exact syntax).

I don't know if this would be considered a good thing or a bad thing...

-dc