What is primary key and unique key?
The primary key (or unique key) of a relational table is a candidate key to uniquely identify each row in a table.
A unique key must uniquely identify all possible rows that exist in a table and not only the currently existing rows. It can either be a normal attribute that is guaranteed to be unique (such as Social Security Number in a table with no more than one record per person) or it can be generated by the DBMS (such as a globally unique identifier, or GUID, in Microsoft SQL Server).
A primary key is a special case of unique key. Primary keys may consist of a single attribute or multiple attributes in combination. And it’s unique, what the difference from the unique key is the primary key cannot be NULL, and primary keys must be defined by using another syntax. Depending on its design, a table may have arbitrarily many unique keys but at most one primary key.
For example, if we have a Students table that contains a record for each student at a university. The student's unique student ID number would be a good choice for a primary key in the Students table. The student's first and last name would not be a good choice, as there is always the chance that more than one students might have the same name.
Defining primary keys:

Defining unique keys:

Tags: primary key unique key table database
Readers also visit these:
What is data, database (DB), DBMS and DBS?How to compare and synchronize the data in different database tables?
Can you show me the commands in each tab in the main interface?
What is date type?
What is T-SQL (Transact-SQL)?
Related Questions:
What is Database Integrity?What is foreign key?
What is data, database (DB), DBMS and DBS?
What is role?
Technical Support
Latest News
- How to connect to SQ...
- How to install Datab...
- How to remove SQL Se...
- How to compare and s...
- How many database ob...
- How to compare and s...
Awards
Customer Service |
| If you have any question or suggestion,please contact us. |
| Get Help>> |
:
: 

