the "UNIQUE" keyword | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

the "UNIQUE" keyword

is it any different from DISTINCT?

13th May 2020, 4:24 AM
Ahmad Saeed
2 Answers
+ 3
The main difference between unique and distinct is that UNIQUE is a constraint that is used on the input of data and ensures data integrity. While DISTINCT keyword is used when we want to query our results or in other words, output the data. Both UNIQUE and DISTINCT key words ensure the same thing, i.e. data is not repeated. One makes sure during input and other during the output.
13th May 2020, 4:57 AM
James Clark I. Vinarao
James Clark I. Vinarao - avatar
+ 2
SELECT UNIQUE works in Oracle databases, but it is not standard SQL. To retrieve unique values from a column, SELECT DISTINCT is more universal and works in every database engine. UNIQUE keyword is otherwise used as a constraint when you create tables.
13th May 2020, 4:59 AM
Tibor Santa
Tibor Santa - avatar