Of Interest
Be responsible for your future Enter the USA legally!
Visa, Green Card, Citizenship, Passport Consultation Services
|
Sybase
»
DDL
»
Design
»
Creating a constraint
Contraints are used to define primary keys, enforce uniqueness, and to describe
foreign key relationships. Note that unique or primary key constraints
create indexes upon creation.
/* primary key for the employee table */
alter table employee add constraint
emp_constr primary key(emp_id)
go
/* add unique requirement for invoice table */
alter table invoice add constraint
inv_constr unique nonclustered(cust_id,inv_date)
go
/* add foreign key for relationship between invoice and employee */
alter table invoice add constraint inv_fk_emp
foreign key (sales_rep_id)
references employee(emp_id)
go
|
|
|
Get the latest Rocket99 news and tech tips via
|