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 is field delimiter?
How do I run a sql query?
how to write date and time literals? : Sql dba
Does a primary key have to be a number?
How to Execute a Package in PL/SQL.?
How do I write a cron which will run a sql query and mail the results to agroup?
What is procedure function?
What is a .db file?
What do you mean by stored procedures? How do we use it?
What is mutating trigger?
Can we use threading in pl/sql?
What is recursive join in sql?
Explain the difference in execution of triggers and stored procedures?
how would you enter characters as hex numbers? : Sql dba
Does pdo prevent sql injection?