Education列。将Name,设为主键,作为列Name的约束。对
EmployeesID列进行UNIQUE约束,并作为表的约束。
create table Employees5
(
EmployeesID char(6) not null,
Name char(6) not null primary key ,
Sex char(2) not null,
Education char(60) not null,
constraint UK_id unique(EmployeesID)
)
2、 删除上题中创建的UNIQUE约束。
alter table Employees5
drop constraint UK_id;
3、 使用T-SQL命令创建一个新表,使用一个复合列作为主
键,作为表的约束,并为其命名。
create table Employees6
(
EmployeesID char(6) not null,
Name char(6) not null ,
Sex char(2) not null,
Education char(60) not null,
constraint PK_id_name primary key(EmployeesID,Name)
)
4、 使用语句为表ALTER TABLEEmployees5添加一个新列
Address,并为该列定义UNIQUE约束,并了解如何使用图形向导
方式删除主键和UNIOQUE约束。
alter table TABLEEmployees5
add Address char(60)
constraint UK_ad unique (Address)
相关文档
评论