2007 Aug 01 2:46 PM
What is the diff between unique and non unique key
2007 Aug 01 2:52 PM
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
2007 Aug 01 2:52 PM
2007 Aug 01 2:54 PM
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
2007 Aug 01 2:54 PM
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.
2007 Aug 01 2:56 PM
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>
2007 Aug 01 3:14 PM
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.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |