Skip to content

Instantly share code, notes, and snippets.

@Nikaoto
Created January 24, 2019 14:38
Show Gist options
  • Save Nikaoto/651a94e90b30ce1d8cdebefd26798d40 to your computer and use it in GitHub Desktop.
Save Nikaoto/651a94e90b30ce1d8cdebefd26798d40 to your computer and use it in GitHub Desktop.
MariaDB foreign key example
create table certificates (
user_row_id int not null unique,
first_name varchar(40) not null,
last_name varchar(50) not null,
email varchar(50) not null,
birth_date date not null,
test_datetime datetime not null,
CONSTRAINT `fk_user_row_id` -- create fk constraint
foreign key (user_row_id) references users (id) -- define constraint
on update restrict -- define when the restriction should apply
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment