By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,251 Members | 2,727 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,251 IT Pros & Developers. It's quick & easy.

CONSTRAINT What for?

P: 1
What is the difference between:
Expand|Select|Wrap|Line Numbers
  1. FOREIGN KEY (CustomerId)  REFERENCES Customers (Id)
AND:
Expand|Select|Wrap|Line Numbers
  1. CONSTRAINT orders_custonmers_fk 
  2.     FOREIGN KEY (CustomerId)  REFERENCES Customers (Id)
1 Week Ago #1

✓ answered by SagarJaybhay

CONSTRAINT clause allows you to define constraint name for the foreign key constraint. If you omit it, MySQL will generate a name automatically.

FOREIGN KEY clause specifies the columns in the child table that refers to primary key columns in the parent table. You can put a foreign key name after FOREIGN KEY clause or leave it to let MySQL create a name for you.

Share this Question
Share on Google+
1 Reply


P: 9
CONSTRAINT clause allows you to define constraint name for the foreign key constraint. If you omit it, MySQL will generate a name automatically.

FOREIGN KEY clause specifies the columns in the child table that refers to primary key columns in the parent table. You can put a foreign key name after FOREIGN KEY clause or leave it to let MySQL create a name for you.
2 Days Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.