How to declare a unique key constraint using mysql table editor?

Is it possible to declare a unique constraint on a column in MYSQL. and can this be done through the MYSQL table editor?
if not what is the correct syntax?
it is very critical for me to solve this right now.. please help..
Thank you,
Pavithra_SAsked:
Who is Participating?
 
Zlatko KuzmanovskiprogrammerCommented:
HI,
Here is the screen. Please look at the RED circles (steps).

Migration from MySQL to MSSQL will not be a problem.

(what is the tool are you using ?)

Regards,
Zlatko.
unique.JPG
0
 
AncientFribCommented:
if the column already exists try:

alter table <TableName> change column <ColumnName> <NewColumnName> <type(int char etc)> PRIMARY KEY

Something like

alter table tbl_table1 change column column1 column1 int PRIMARY KEY

Can probably use UNIQUE instead of PRIMARY too.
0
 
HainKurtSr. System AnalystCommented:
here it is

ALTER TABLE Persons
ADD CONSTRAINT uc_PersonID UNIQUE (P_Id,LastName)
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Pavithra_SAuthor Commented:
Thanks for the suggestion.. it helped!
I used something like
ALTER TABLE tablename
 ADD UNIQUE KEY  USING BTREE(`columnname`);
0
 
Pavithra_SAuthor Commented:
I am going to try the second suggestion too.. will let you know shortly.. thanks for all the help
0
 
Pavithra_SAuthor Commented:
is unique constraint different from unique key?
0
 
HainKurtSr. System AnalystCommented:
in MSSQL they are same ;)

http://blog.sqlauthority.com/2007/04/26/sql-server-difference-between-unique-index-vs-unique-constraint/

when you create a unique constraintsm, it adds a unique index...
0
 
Zlatko KuzmanovskiprogrammerCommented:
Hi,

Please use this steps :
1) Start MySQL Administrator (your of course)
2) Goto Catalogs
3) Select your Database (Catalog)
4) In the "MySQL Table Editor" click on the small icon left of a column name
5) You can click on multiple column icons (to have multiple-column primary key)

Regards,
Zlatko.
0
 
Pavithra_SAuthor Commented:
Yes i noticed that we can have multiple column primary key.. but i need one primary key and the other column to have a unique key constraint...
i am working on MYSQL now.. but need to do thisin such a way that it easily migrates to MSSQL..
is there any particular suggestion with this regard?
once again thank u all for ur help!
0
 
Pavithra_SAuthor Commented:
THANKS!! Exactly what I was looking for.. not sure about the tool they are gonna use.. but trying to make sure it ready to migrate..
0
 
Pavithra_SAuthor Commented:
excellent help on this!  
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.