1) Make sure that the column only conains unique values
lets assume we are working with a table called t5. it has two columns. id ( the primary key ) and name. To find out if the column contains any duplicate values make the following statements.
select name from t5 ;
select distinct name from t5 ;
IF the row counts are the same then the column contains unique values only.
2) Create a unique index as follows..
alter table t5 add unique ( name ) ;
If you want to give the index a name do it this way...
alter table t5 add unique namedex ( name )
3) Drink a beer
That's it!
* You may optionally drink beer between and during steps one and two.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.