I need to alter the properties of a column, and make the values within both UNIQUE and KEY.
from what i have gathered so far...
ALTER TABLE `table_name` CHANGE `initial_column_name` `new_column_name` VARCHAR( 30 ) (other values...where i need to set UNIQUE and PRIMAEY KEY)
I don't know if i am writting the architecture of the code wrong or any other problem, but I was wondering if someone could type out and example for me to see that might clarify where / what I am doing wrong.
Thnx
ALTER -- problems
Moderator: General Moderators
Try doing it in two steps....
Followed by...
If the column you are changing is already the primary key then you don't need to issue the second command.
A column can be unique or a primary key but it can't be set to both (primary keys are unique)
Code: Select all
ALTER TABLE `table_name` CHANGE `initial_column_name` `new_column_name` VARCHAR( 30 ) NOT NULLCode: Select all
ALTER TABLE `table_name` DROP PRIMARY KEY , ADD PRIMARY KEY ( `new_coloumn_name` )A column can be unique or a primary key but it can't be set to both (primary keys are unique)