2
Answers

smarter ways to make a column value unique

George George

George George

16y
3.3k
1

Hello everyone,

I have a table and a couple of columns in this table. For some specific column, it is not primary key, but I want to accept only unique value for this specific column for each row.

Currently, my naive solution is to use a store procedure to handle table insertion and if in the store procedure I find there is already a row whose existing value for the specific column is the same as the new column value of the new row to be inserted, I will return error from the store procedure and refuse to insert the whole new row.

Any other smarter ways?

thanks in advance,
George

Answers (2)
Next Recommended Forum