distal-attribute
distal-attribute
distal-attribute
distal-attribute

defining primary key after table creation

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

Thanks

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

see also:
http://www.heidisql.com/forum/viewtopic.php?t=228
rando posted 7 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 7 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.

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