//数据库的插入
--在数据库中根据上述表的定义创建上述数据库,同时需建立相应的约束关系
create table [EMPLOYEE](
[EmpNo] varchar(8) not null primary key,
[EmpName] varchar(50) not null,
[EmpSex] varchar(2) check([EmpSex]='男' or [EmpSex]='女'),
[EmpAge] int check([EmpAge]>0)
)
create table [COMPANY](
[CmpNo] varchar(8) not null primary key,
[CmpName] varchar(50) not null
)
create table [WORKS](
[EmpNo] varchar(8) references [EMPLOYEE]([EmpNo]),
[CmpNo] varchar(8) references [COMPANY]([CmpNo]),
[Salary] int check([Salary]>0)
--将上面的数据输入到数据库中相应的表中
insert into [EMPLOYEE] values('E01','张三','女',32);
insert into [EMPLOYEE] values('E02','李四','男',28);
insert into [EMPLOYEE] values('E03','王五','女',42);
insert into [EMPLOYEE] values('E04','赵六','男',37);
insert into [EMPLOYEE] values('E05','陈七','男',51);
insert into [COMPANY] values('C01','阳光科技');
insert into [COMPANY] values('C02','晨光科技');
insert into [COMPANY] values('C03','未来科技');
insert into [WORKS] values('E01','C01',3000);
insert into [WORKS] values('E01','C02',4000);
insert into [WORKS] values('E02','C02',5000);
insert into [WORKS] values('E02','C03',2500);
insert into [WORKS] values('E03','C01',3500);
insert into [WORKS] values('E04','C02',3000);
网友评论