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
What do we need to check in database testing?
What is difference between procedure and trigger?
how to analyze tables with 'mysqlcheck'? : Sql dba
What is partition in sql query?
What is the meaning of disabling a trigger?
What is the usage of nvl function?
Why are indexes and views important to an organization?
What is the purpose of normalization?
What is group function in sql?
What is field delimiter?
Does sql support programming?
Why is sql important?
Is primary key an index?
How to add new employee details in an employee_details table with the following details
Can we call dml statement in function?