Friends

Tuesday, May 31, 2011

Adding Constraints

Add foreign key to existing table

alter table Empdetails add constraint fk_cat foreign key (cat_id) references tbl_category(cat_id)

Add constraint in create table

create table table2
(
cat_id int not null,
category varchar(100),
empid int,
primary key(cat_id),
constraint fk_hi foreign key (empid) references empdetails(empid)
)

No comments:

Post a Comment