Differences between UNIQUE and DISTINCT in select statements

Answer Posted / manoj

see cautiously the major difference b/w unique and
distinct

UNIQUE :Allways take part on DATA INSERTION (In brief)
DINTINCT:Allways concern on data retrival (In brief)

Now we will take following case
when

case 1: UNIQUE KEY is defined (may b 4 one or more column)

It means this constraint will not allow us to
INSERT duplicate record/column_value(s)(i.e. exactly
same record/column_value(s) again for specified key column
(s)only)


NOW if u use DISTINCT clause in query
(select DISTINCT.from.)the will b same as simple query
(select....from...)

Bcoz data are already not repeated (bcoz of constraint)


case 2:if UNIQUE not defined

data may b repeated and DISTINCT will now useful


Have eye on Major difference

(and we never use UNIQUE CONS.. in select.....)

Is This Answer Correct ?    40 Yes 31 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is sql profiler? : Sql dba

577


What are sql ddl commands?

536


What is pl sql and why it is used for?

561


Why is stored procedure faster than query?

482


What is the difference between explicit and implicit cursors in oracle?

502






List different type of expressions with the example.

544


Write a sql query to get the third highest salary of an employee from employee_table?

622


Do foreign keys improve performance?

537


What is microsoft t sql?

483


What is substitution variable?

565


What are the various levels of constraints?

655


Mention what does the hierarchical profiler does?

548


What are different types of triggers?

547


How to run sql functions in pl/sql?

532


How global cursor can be declare with dynamic trigger ?

1739