Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Differences between UNIQUE and DISTINCT in select statements

Answer Posted / karthicksharma

As said earlier UNIQUE is a constraint and can be used
during a table creation to prevent duplication of data .

-----------------------------------------------------
CREATING A TABLE USING UNIQUE CONSTRAINT:
=================================================

eg:
SQL> create table empl1 (name varchar2(15),no number(5)
unique);

Table created.

-----------------------------------------------------

So from this it is clearly implied that UNIQUE constraint
is used to prevent INSERTION AS WELL AS RETRIVAL of non-
duplicate data.

whereas DISTINCT clause can only be used for RETRIVAL of
non-duplicate data.

Whereas DISTINCT is a clause and cannot be used during a
table creation to limit the duplication of data.

-----------------------------------------------------
CREATING A TABLE USING DISTINCT CLAUSE:
===========================================
eg:
create table empl2(name varchar2(15),no number(5) distinct)
*
ERROR at line 1:
ORA-00907: missing right parenthesis

-----------------------------------------------------

Is This Answer Correct ?    7 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is sql microsoft?

1038


What is the difference between function and procedure in pl/sql?

1069


how to add a new column to an existing table in mysql? : Sql dba

1062


How run sql*plus commands that are stored in a local file?

1053


How do temporal tables work?

951


what is the difference between a having clause and a where clause? : Sql dba

1073


What is difference between stored procedure and trigger?

1153


What is primary key and unique key?

1111


How many primary keys can a table have?

1000


Mention what does the hierarchical profiler does?

1081


How do I partition in sql?

956


What is the difference between functions, procedures, and packages in pl/sql?

1038


What are sql data types?

1013


Why do we need unique key in a table?

952


Can a composite key be null?

970