469,342 Members | 5,849 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,342 developers. It's quick & easy.

CONSTRAINT What for?

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)
Aug 11 '19 #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.

1 1992
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.
Aug 20 '19 #2

Post your reply

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

Similar topics

26 posts views Thread by Agoston Bejo | last post: by
4 posts views Thread by wireless | last post: by
10 posts views Thread by Laurence | last post: by
2 posts views Thread by Kenneth Koenraadt | last post: by
15 posts views Thread by Frank Swarbrick | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.