From 07bf7dac2ce7011f8593eac981f209b8974dd95a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E9=87=91=E9=87=91?= <1665966989@qq.com> Date: Fri, 16 Sep 2022 05:05:21 +0000 Subject: [PATCH] =?UTF-8?q?=E8=B0=A2=E9=87=91=E9=87=9126?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 谢金金 <1665966989@qq.com> --- .../9.15biji.txt" | 11 ++ .../zy9.15.sql" | 101 ++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 "\350\260\242\351\207\221\351\207\221/9.15biji.txt" create mode 100644 "\350\260\242\351\207\221\351\207\221/zy9.15.sql" diff --git "a/\350\260\242\351\207\221\351\207\221/9.15biji.txt" "b/\350\260\242\351\207\221\351\207\221/9.15biji.txt" new file mode 100644 index 0000000..edc597e --- /dev/null +++ "b/\350\260\242\351\207\221\351\207\221/9.15biji.txt" @@ -0,0 +1,11 @@ +create database 创建数据库 +use DBTEST使用当前数据库 +create table 创建表 +primary key主键 +identity(1,1)自增 + not null非空 + check 约束 +unique 唯一约束 +references +表名(字段) 外键 +check(userAge between 1 and 100) +限制年龄 \ No newline at end of file diff --git "a/\350\260\242\351\207\221\351\207\221/zy9.15.sql" "b/\350\260\242\351\207\221\351\207\221/zy9.15.sql" new file mode 100644 index 0000000..ed10867 --- /dev/null +++ "b/\350\260\242\351\207\221\351\207\221/zy9.15.sql" @@ -0,0 +1,101 @@ + +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 + create database DBTEST; + use DBTEST; + create table sectionInfo( + sectionID int primary key identity(1,1), + sectionName varchar(10) not null, + ) + create table userInfo( + userNo int primary key identity(1,1) not null, + userName varchar(10) check(len(userName)>4) unique not null, + 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) + ) + create table workInfo( + workId int primary key identity(1,1) 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='事假') + ) + insert into sectionInfo(sectionName) + values('张三') + insert into sectionInfo(sectionName) + values('李四') + insert into sectionInfo(sectionName) + values('王五') + insert into sectionInfo(sectionName) + values('老六') + insert into sectionInfo(sectionName) + values('七七') + insert into userInfo(userName,userSex,userAge,userAddress,userSection) + values('张三','男','28','福建','1') + insert into userInfo(userName,userSex,userAge,userAddress,userSection) + values('李四','男','38','江西','2') + insert into userInfo(userName,userSex,userAge,userAddress,userSection) + values('王五','男','48','福建','3') + insert into userInfo(userName,userSex,userAge,userAddress,userSection) + values('老六','男','18','湖北','4') + insert into userInfo(userName,userSex,userAge,userAddress,userSection) + values('七七','女','18','重庆','5') + insert into workInfo(userId,workTime,workDescription) + values('1','2022年9月15日17:21:04','迟到') + insert into workInfo(userId,workTime,workDescription) + values('2','2022年9月15日17:21:07','早退') + insert into workInfo(userId,workTime,workDescription) + values('3','2022年9月15日17:21:15','旷工') + insert into workInfo(userId,workTime,workDescription) + values('1','2022年9月15日17:21:28','迟到') + insert into workInfo(userId,workTime,workDescription) + values('1','2022年9月1日17:21:09','迟到') + -- Gitee