Database - Introduction to SQL - Discussion

Discussion Forum : Introduction to SQL - General Questions (Q.No. 19)
19.
To remove duplicate rows from the results of an SQL SELECT statement, the ________ qualifier specified must be included.
ONLY
UNIQUE
DISTINCT
SINGLE
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
9 comments Page 1 of 1.

Azhar said:   4 years ago
Unique is constraint but distinct is not a constraint.

Hrishikesh Joshi said:   5 years ago
"Specify DISTINCT or UNIQUE if you want Oracle to return only one copy of each set of duplicate rows selected (these two keywords are synonymous). Duplicate rows are those with matching values for each expression in the select list.

So, there should be no difference in the two (performance or otherwise) as they are treated the same by Oracle.

On another note, don't try to use UNIQUE in SELECT statements for other databases (MySQL, PostgreSQL, etc). You get up with an error because ANSI standards use DISTINCT with SELECT statements. Using UNIQUE with SELECT statements is just a product-specific remnant of older Oracle DBs created before the ANSI standard was born.

Kishor said:   6 years ago
Select unique * from emp, it is also showed unique data.

Manoj said:   6 years ago
Unique is for primary key, distinct removes duplicity in data.

Vasanth said:   8 years ago
Really unique and distinct keywords are same?

Pradeep said:   9 years ago
What about UNIQUE keyword ?

Both unique and distinct are same ?

Rajendra said:   10 years ago
Oracle official documentation:

http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_10002.htm#sthref9346

States that:

DISTINCT | UNIQUE

Specify DISTINCT or UNIQUE if you want the database to return only one copy of each set of duplicate rows selected. These two keywords are synonymous. Duplicate rows are those with matching values for each expression in the select list.

Aditya Harsha.R said:   1 decade ago
Yes. Because Its Keyword .

SELECT DISTINCT column_name(s)
FROM table_name

P_Id	LastName	FirstName     Address	City
1 Hansen Timoteivn 10 Sandnes
2 Svendson Borgvn 23 Sandnes
3 Pettersen Storgt 20 Stavanger


SELECT DISTINCT City FROM Persons

The result-set will look like this:

City
Sandnes
Stavanger

I think its Right.

Shashi said:   1 decade ago
Distinct remove the duplicate rows from the row.

Post your comments here:

Your comments will be displayed after verification.