hi, using constraint at creation table. other we can use alter the particular column....
ALTER TABLE TableName
ADD CONSTRAINT uk_username UNIQUE KEY (UserName)