.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Interview Question >> Others >> Post New Question Subscribe to Interview Questions

What is the difference between unique and primary keys in Oracle SQL?

Posted By :Shala     Posted Date :June 01, 2010    Points :10   Category :Others 
A table can have only one PRIMARY KEY whereas there can be any number of UNIQUE keys. The columns that compose PrimaryKey are automatically defined as NOT NULL, whereas a column that compose a UNIQUE is not automatically defined to be mandatory must also specify the column is NOT NULL.


You can also find related Interview Question to What is the difference between unique and primary keys in Oracle SQL?  below: 

What's the difference between a primary key and a unique key?

  
Both primary key and unique enforce uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a nonclustered index by default. Another major difference is that, primary key doesn't allow NULLs, but unique key allows one NULL only. (More...)

What's the difference between a primary key and a unique key?

  
Both primary key and unique key enforces uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a nonclustered index by default. Another major difference is that, primary key doesn't allow NULLs, but unique key allows one NULL only (More...)

Difference between primary and unique key constraints

  
Unique Key Constraints
The column values should retain uniqueness.
It allows null values in the column.
It will create non-clustered index by default.
Any number of unique constraints can be added to a table.


Primary Key Constraints
Primary key will create column data uniqueness in the table.
It will not allow Null values.
By default Primary key will create clustered index.
Only one Primary key can be created for a table.
(More...)

Difference between Primary key and unique key?

  
Primary key dont allow null values where as Unique key allow null value.
Primary key create clustured index on column whereas unique key create non-clustured index. (More...)

Difference between Primary and Unique key.

  
Primary Key:
A column defined as primary key doesn’t allow null value.
By default, clustered index in created with the column having primary key.
Unique Key:
A column with unique key defined allows null value.
By default, it creates non-clustered index. (More...)

Difference between Unique Key and Primary Key

  
1. A UNIQUE constraint is similar to PRIMARY key, but you can have more than one UNIQUE constraint per table.
2. Primary Key does not allow null values whereas unique constraint allows 'single' null value.
3. A table can have only single Primary Key where as it can have multiple unique constraints ( max 16)
4. Primary Key creates clustered index by default whereas Unique Key creates non-clustered index by default
(More...)

What is difference between Primary Key and Unique Key?

  
1.Primary Key can't accept null values Whereas Unique key can accept only one null value.

2.By default, Primary key is clustered index and data in the database table is physically organized in the sequence of clustered index whereas Unique key is a unique non-clustered index.

3.We can have only one Primary key in a table Whereas We can have more than one unique key in a table.
(More...)

What are primary keys and foreign keys?

  
Primary keys are the unique identifiers for each row. They must contain unique values and cannot be null. Due to their importance in relational databases, Primary keys are the most fundamental of all keys and constraints. A table can have only one Primary key.
Foreign keys are both a method of ensuring data integrity and a manifestation of the relationship between tables.


Shashi Ray (More...)

Difference between oracle, sql and sqlserver?

  
Oracle is based on RDBMS.SQL is structured query language,pronounced "sequel", is a language that provides an interface to relational database systems.and sql server is tool for RDBMS provided b Microsoft. (More...)

What are primary keys and foreign keys?

  
Primary keys are the unique identifiers for each row. They must contain unique values and cannot be null. Due to their importance in relational databases, Primary keys are the most fundamental of all keys and constraints. A table can have only one Primary key.
Foreign keys are both a method of ensuring data integrity and a manifestation of the relationship between tables. (More...)

what is the difference between primary key and foreign key?

  
A primary key is a column which uniquely identifies the
records in a table. In a broad sense, a primary key is the
mixture of a unique key and an index: A collumn with a primary
key is indexed to deliver a faster query, and doesn't allow
duplicate values to ensure specific data.

A foreign key is a column (the child collumn) in a table which
has a corresponding relationship and a dependency on another
collumn (the parent collumn) that is usually in a different
table. Parent collumns can have multiple child collumns, but a
child collumn can only have one parent collumn.

Primary key does't allow null value
while foreign key allow null value
(More...)

How do we get primary key information in oracle table?

  
we can get primary key information with the following SQL statement

SELECT b.table_name, b.column_name, b.position, a.status, cons.owner
FROM all_constraints a, all_cons_columns b
WHERE cons.constraint_type = 'P'
AND a.constraint_name = b.constraint_name
AND a.owner = b.owner
ORDER BY b.table_name, b.position;
(More...)

What Are Primary Keys?

  
Primary keys are the unique identifiers for each row. They must contain unique values and cannot be null. Due to their importance in relational databases, Primary keys are the most fundamental of all keys and constraints. A table can have only one Primary key. (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

 
Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.


Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend