I have some records that I need to store in a database table and I want to distinguish one record from other records on the basis of name field.
But as the datatype of name field is varchar, it will effect the performance because comparing varchar data with each other is time consuming process in comparision to a numeric field.
So I want each record to have a unique numeric field (say id). But if I make the id as primary key, then the more than one record can contain same name.
What’s the solution to the above problem?
You can still create a
UNIQUEconstraint on thenamefield:The
UNIQUEconstraint, like thePRIMARY KEYconstraint, will guarantee that your column will contain only unique values.Note that you can have many
UNIQUEconstraints per table, but only onePRIMARY KEYconstraint.