Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

What is the diff between unique and non unique key

Former Member
0 Likes
14,153

What is the diff between unique and non unique key

What is the diff between unique and non unique key

6 REPLIES 6
Read only

Former Member
0 Likes
6,374

Hi Srikanth,

A unique key would be helpful in determining a single record from the internal table while performing a search using that key.

Whereas, a non-unique key would not be able to distinctly find out a specific single record for the search that is made using that key. In a table which uses a non-unique key Read statement would pick the first record which shall validate the search criteria.

<b>Reward points if this helps,</b>

Kiran

Read only

RichHeilman
Developer Advocate
Developer Advocate
Read only

Former Member
0 Likes
6,374

Hi,

The optional additions UNIQUE or NON-UNIQUE determine whether the key is to be unique or non-unique, that is, whether the table can accept duplicate entries. If you do not specify UNIQUE or NON-UNIQUE for the key, the table type is generic in this respect. As such, it can only be used for specifying types. When you specify the table type simultaneously, you must note the following restrictions:

You cannot use the UNIQUE addition for standard tables. The system always generates the NON-UNIQUE addition automatically.

You must always specify the UNIQUE option when you create a hashed table.

Regards

Sudheer

Read only

Former Member
0 Likes
6,374

hi

<b>Primary key</b>

Both are same.A primary key is usually called as an unique key.A primary key is defined for each database table. A user-defined primary key can consist of one or more columns.The primary key must have a unique value for each table row. The primary key is either defined by the database user, or generated internally.

The Main difference is that Unique Key allows null value but Primary Key doesn't allow null values.

<b>

Foreign key</b>

If the values in a column (or a combination of columns) of a table always match the values of the primary key column of another table, then this column (or combination of columns) is called a foreign key.

Read only

Former Member
0 Likes
6,374

tables with a unique key cannot contain duplicate entries.

Primary key

Both are same.A primary key is usually called as an unique key.A primary key is defined for each database table. A user-defined primary key can consist of one or more columns.The primary key must have a unique value for each table row. The primary key is either defined by the database user, or generated internally.

Foreign key

If the values in a column (or a combination of columns) of a table always match the values of the primary key column of another table, then this column (or combination of columns) is called a foreign key.

regards,

srinivas

<b>*reward for useful answers*</b>

Read only

Former Member
0 Likes
6,374

hi,

unique key -- allows to have null values. but data should not be redundant.

non unique keys [primary , foreign .......] - depends on whichkey we r using.

if helpful reward some points.

with regards,

Suresh Aluri.