CONSTRAINT What for?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • IlyaJava
    New Member
    • Aug 2019
    • 1

    CONSTRAINT What for?

    What is the difference between:
    Code:
    FOREIGN KEY (CustomerId)  REFERENCES Customers (Id)
    AND:
    Code:
    CONSTRAINT orders_custonmers_fk 
        FOREIGN KEY (CustomerId)  REFERENCES Customers (Id)
  • SagarJaybhay
    New Member
    • Feb 2019
    • 17

    #2
    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.

    Comment

    Working...