Skip to content

Instantly share code, notes, and snippets.

@YurePereira
Last active September 28, 2016 20:06
Show Gist options
  • Select an option

  • Save YurePereira/492555b37258dd0b9707635a81926629 to your computer and use it in GitHub Desktop.

Select an option

Save YurePereira/492555b37258dd0b9707635a81926629 to your computer and use it in GitHub Desktop.
Using Foreign Key with MySql and Constraint
-- Using Foreign Key with MySql and Constraint:
alter table <name_table>
add constraint <fk_name_constraint_1>
foreign key (<column_name_this_table>)
references <table_references> (<column_name_table_references>);
-- Not tested:
alter table <name_table>
add constraint <fk_name_constraint>
foreign key (<name_id>, <name_id_2>, <name_id_3>)
references <table_references> (<name_id>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment