Differences between UNIQUE and DISTINCT in select statements
Answers were Sorted based on User's Feedback
Answer / anilkumar kambala
UNIQUE:
UNIQUE CAN TAKE UNIQUE DATA
USING DISTINCT CLAUSE SORTING THE DATA
| Is This Answer Correct ? | 4 Yes | 1 No |
Answer / pravin d. survase
UNIQUE is only used in oracle but,
DISTINCT is used in all RDBMS.
UNIQUE is used in SELECT statement and as KEY also.
DISTINCT is only used in SELECT.
DISTINCT KEY concept is not present in SQL/ORACLE.
UNIQUE also supress the duplicates but, UNIQUE KEY will
allow the duplicates.
DISTINCT supress the duplicates.
| Is This Answer Correct ? | 4 Yes | 2 No |
Answer / prabha
Distinct:
Its gives only the non duplicate values in a database table.
Unique:
The UNIQUE constraint uniquely identifies each record in a
database table.its similar to primary key.these values
cannot be repeated.
| Is This Answer Correct ? | 3 Yes | 1 No |
Answer / carol
unique is a constraint on coloumnsbut distinct is used in DML for query retrieval in select
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / cutepa1
Yeah Manoj, Thatz ok, UNIQUE as a constraint. But I like to
know about the diff while its usage in select statement. For
me it seems very similar to DISTINCT, can anyone give me if
there is any difference, please.
| Is This Answer Correct ? | 15 Yes | 15 No |
Answer / howard cheon
DISTINCT AND UNIQUE are same operation.
But, You cannot specify DISTINCT if the select_list
contains LOB columns.
| Is This Answer Correct ? | 16 Yes | 16 No |
Answer / hemasundar
Distinct:Its gives only the non duplicate values in a database table.
Unique:The UNIQUE constraint uniquely identifies each record in a database table.its similar to primary key.these values
cannot be repeated.But, nearly both are same...
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / narendrasai
UNIQUE: it is a constraint and it was created at the time of table creation, where as
DISTINCT: it is a word used at the time of selection.
So both are same, but usage of both the words are different
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / vijay mohan reddy
Hi Howard Cheon,
you are currect... but we cant able to use
both DISTINCT and UNIQUE, if the select_list contains LOB,
LONG columns. It may not a difference.
Could anyone plz give some another major difference..
Thanks in Advance
Vijay Reddy.
| Is This Answer Correct ? | 9 Yes | 10 No |
Answer / ajeet
there is no diff between distinct and unique in user point
of view. both are same. same functionality. dont bother
about it use whatever you want....
| Is This Answer Correct ? | 4 Yes | 5 No |
What is pl sql package?
How does sql*loader handles newline characters in a record? : aql loader
How well can multiple sessions access the same data simultaneously ?
what is foreign key? : Sql dba
how to get a list of indexes of an existing table? : Sql dba
What is user defined functions?
What are the parts of a basic sql query?
Hi Guys, I have a situation where I need to access the column values from rowtype variable. However, the column names are dynamic. below is sample code: declare Cursor c1 is select * from emp; Cursor c2 is select column_name from xyztable; v_c2 c2%rowtype; v_str varchar2 v_value varchar2(200); begin for rec in c1 loop open c2;---this cursor has column names like EMPLOYEE_ID, FIRST_NAME, LAST_NAME etc. loop fetch c2 into v_c2; exit when c2%notfound; /* now lets say i want to access value of LAST_NAME from cursor c1, so I am writing below code, however it does not work as expected */ v_str:= 'rec.'|| v_c2.column_name; -- this will give me string like "rec.EMPLOYEE_ID" v_value:=v_str; end loop; end loop; end; / Plz help ASAP.Thanks.
How can you maintain the integrity of your database on instances where deleting an element in a table result in the deletion of the element(s) within another table?
Explain what is a database?
What is a call statement? Explain with an example.
what is the difference between cluster and non cluster index? : Sql dba
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)