sql - Why use named key constraint (Eg: Foreign Key) -


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

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -