defining primary key after table creation

[expired user #2236]'s profile image [expired user #2236] posted 17 years ago in General Permalink
How do I, using Heidi, define a field as a primary key after the table has already been created.

Thanks

Dan Landis
[expired user #1821]'s profile image [expired user #1821] posted 17 years ago Permalink
right click any of the column-names and choose the option 'manage indexes'

see also:
http://www.heidisql.com/forum/viewtopic.php?t=228
[expired user #2827]'s profile image [expired user #2827] posted 17 years ago Permalink
Same problem. I have created a new field which I first want to be the primary key and then autoincrement field.

When I try to set the field as primary key, I get twice an error message
data truncated for column 'my field' at row 1.

What is wrong?
jan's profile image jan posted 17 years ago Permalink
just remember, that the primary-key is unique. so when you want to add this key, the data in this row has to be unique.

select id, count(*) from table group by id having count(*) <> 1

gives you all your dups.



the primary-key has nothing to do with the auto-increment. but you can only set the auto-increment to an primary-column. so first, add the new column, then change/add the primary key to this column and then edit the column and set the auto-increment.
[expired user #10304]'s profile image [expired user #10304] posted 7 years ago Permalink

Thanks for your help. If I can't replace rows on import I'm considering deleting all the rows and then re-importing the new data. I'll need to do some testing.

Please login to leave a reply, or register at first.