Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Primary Key only and Primary Key constraint?

I am very new to SQL and if my question is silly please forgive my ignorance.

What is the difference between Primary Key only and Primary Key constraint?

Difference between This

CREATE TABLE CUSTOMERS(
   ID   INT              NOT NULL,
   PRIMARY KEY (ID, NAME)

and This

CREATE TABLE CUSTOMERS(
   ID   INT              NOT NULL,
  CONSTRAINT [Pk_ID_Name] PRIMARY KEY (ID, NAME)

Thank you, Dash

like image 745
Dasso Avatar asked Apr 18 '13 14:04

Dasso


1 Answers

In the second version, you can give a name to your constraint, allowing you to drop it using the name instead of having to name every column of a composite constraint.

Otherwise, they do the same thing.

like image 74
Raphaël Althaus Avatar answered Sep 26 '22 05:09

Raphaël Althaus