defining primary key after table creation

landisd posted 10 years ago in General
How do I, using Heidi, define a field as a primary key after the table has already been created.


Dan Landis
siMKin posted 10 years ago
right click any of the column-names and choose the option 'manage indexes'

see also:
rando posted 10 years ago
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 posted 10 years ago
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.
morgothik posted 11 months ago

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.