difference between a primary key and a unique key?

difference between a primary key and a unique key?

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

View Answers

November 15, 2010 at 12:52 PM

Hi,

The column holding the primary key constraint cannot accept null values.whereas column holding the unique constraint can accept null values.

Both primary key and unique enforce uniqueness of the column on which they are defined. But by default primary key creates a clustered index(physical sorting of a database table?s) on the column, where are unique creates a non clustered index (sorted list of references to the table itself.) by default. Another major difference is that, primary key doesn't allow Nulls, but unique key allows one NULL only.

Thanks,









Related Tutorials/Questions & Answers:
difference between a primary key and a unique key?
Difference between not null and primary key in mysql
Advertisements
primary key and unique key
primary key and unique key
What is a "primary key"?
SQL PRIMARY KEY Constraint
SQL Auto increment Primary Key
Mysql Alter Unique Key
SQL PRIMARY KEY Constraint
composinte primary key in hibernate
JDBC insert that returns primary key
Difference between DispatchAction and LookupDispatchAction
difference between SessionState and ViewState
difference between ForwardAction and IncludeAction
Difference between struts and JSF
difference between == and === operators?
PHP Array Unique Key
Create primary key using hibernate
Adding A Primary Key to an Existing Table
SQL Alter Table Primary Key
Difference between 3d and 4d
What is the difference between the >> and >>> operators?
difference between varchar & varchar2?
changing primary key of parent table
Mysql add primary key
SQL Primary Key
How to create primary key using hibernate?
Difference between Mysql and SQL
Difference between Timer and Thread?
Hibernate unique key validation example
hibernate annotations with composite primary key
Mysql Alter Table Primary Key
what is the difference between extends and implements
what is the difference between extends and implements
Difference between SCJP Exams
Difference between JSP and Servlets
difference between lock and synchronization
Difference between session.save() , session.saveOrUpdate() and session.persist() in Hibernate
how tohow to create a table with primary key and foreign keyhow to create a table with primary key and foreign key
ModuleNotFoundError: No module named 'django-uuid-primary-key'
Difference between request.getRequestDispatcher() and context.getRequestDispatcher()
Difference between forward and sendRedirect
Difference between ServletContext and ServletConfig
Difference between translate and replace
Mysql Alter Column Primary Key
Difference between GET and POST
What is the difference between PHP4 and PHP5?
What is difference between a PROCEDURE & FUNCTION ?
Difference between XML and HTML - XML
difference between <%@ include ...> and <jsp:include>

Ads