sql - Why use named key constraint (Eg: Foreign Key) -
this question has answer here:
i not familiar sql
, please explain me difference of following 2 , best way use. there advantage using 1 on another.
create table employee ( emp_id int not null, dep_id int not null, ... foreign key (dep_id) references department(dep_id) );
and
create table employee ( emp_id int not null, dep_id int not null, ... constraint fk_empdept foreign key (dep_id) references department(dep_id) );
the difference in naming. if don't explicitly set name constraint, has auto generated name. example: fk_employee_dep_id__164452b1 . , you'll see name in description of table keys, in different exceptions , on.
Comments
Post a Comment