diff --git "a/\345\274\240\345\205\210\346\235\260/.keep" "b/\345\274\240\345\205\210\346\235\260/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\345\274\240\345\205\210\346\235\260/\345\274\240\345\205\210\346\235\260/SQLQuery1.sql" "b/\345\274\240\345\205\210\346\235\260/\345\274\240\345\205\210\346\235\260/SQLQuery1.sql" new file mode 100644 index 0000000000000000000000000000000000000000..e112875f6bb91ebce91b4dbcfdc5c26227116840 --- /dev/null +++ "b/\345\274\240\345\205\210\346\235\260/\345\274\240\345\205\210\346\235\260/SQLQuery1.sql" @@ -0,0 +1,71 @@ +--创建数据库 DBTEST +if exists (select * from sys.databases where name = 'DBTEST') +drop database DBTEST +create database DBTEST; + + +--部门信息表(sectionInfo) +-- 部门编号 sectionID int 标识列 主键 +-- 部门名称 sectionName varchar(10) 不能为空 + +create table sectionInfo( + sectionID int primary key identity(1,1), + sectionName varchar(10) not null +) + +insert sectionInfo values('研发'); +insert sectionInfo values('生产'); +insert sectionInfo values('财务'); +insert sectionInfo values('人事'); +insert sectionInfo values('计划'); + +-- select * from sectionInfo; + +--员工信息表(userInfo) +-- 员工编号 userNo int 标识列 主键 不允许为空 +-- 员工姓名 userName varchar(10) 唯一约束 不允许为空 长度必须大于4 +-- 员工性别 userSex varchar(2) 不允许为空 只能是男或女 +-- 员工年龄 userAge int 不能为空 范围在1-100之间 +-- 员工地址 userAddress varchar(50) 默认值为“湖北” +-- 员工部门 userSection int 外键,引用部门信息表的部门编号 + +--drop table userInfo; + +create table userInfo ( + userNo int identity(1,1) primary key not null, + userName varchar(10) unique not null check(len(userName) > 4), + userSex varchar(2) not null check(userSex = '男' or userSex = '女') , + userAge int not null check(userAge between 1 and 100), + userAddress varchar(50) default '湖北', + userSection int references sectionInfo(sectionId) +); + +insert userInfo (userName,userSex,userAge,userAddress,userSection) +values ('张三123','男','25','福建','1'), + ('李四123','女','30','上海','2'), + ('王五123','女','36','上海','3'), + ('赵六123','女','40','广州','4'), + ('11223','女','27','广州','5'); +--select * from userInfo + +--员工考勤表(workInfo) +-- 考勤编号 workId int 标识列 主键 不能为空 +-- 考勤员工 userId int 外键 引用员工信息表的员工编号 不能为空 +-- 考勤时间 workTime datetime 不能为空 +-- 考勤说明 workDescription varchar(40) 不能为空 内容只能是“迟到”,“早退”,“旷工”,“病假”,“事假”中的一种 + +create table workInfo( + workId int identity(1,1) primary key not null, + userId int references userInfo(userNo) not null, + workTime datetime not null, + workDescription varchar(40) not null check(workDescription = '迟到' or workDescription = '早退' or workDescription = '旷工' or workDescription = '病假' or workDescription = '事假') +) +insert workInfo(userId,workTime,workDescription) +values (1,'2022-1-15 15:15:1','迟到'), + (2,'2022-1-16 15:15:1','早退'), + (3,'2022-1-14 15:15:1','旷工'), + (4,'2022-1-16 15:15:1','病假'), + (5,'2022-1-12 15:15:1','事假'); + + +--select * from workInfo \ No newline at end of file diff --git "a/\345\274\240\345\205\210\346\235\260/\345\274\240\345\205\210\346\235\260/\347\254\224\350\256\260.md" "b/\345\274\240\345\205\210\346\235\260/\345\274\240\345\205\210\346\235\260/\347\254\224\350\256\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..2584ad8b1bcba6e12d70b22019e34f649559cefa --- /dev/null +++ "b/\345\274\240\345\205\210\346\235\260/\345\274\240\345\205\210\346\235\260/\347\254\224\350\256\260.md" @@ -0,0 +1,2 @@ +鍝庡樋 +