From 39595bf48bbfd1a5dd0fd537e698189daca8529c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E7=8E=AE=E5=96=86?= Date: Fri, 16 Sep 2022 13:12:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\344\275\234\344\270\232/SQLQuery1.sql" | 49 +++++++++++++++++++ .../\347\254\224\350\256\260/Note.md" | 38 ++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 "04\351\203\221\347\216\256\345\226\206/\344\275\234\344\270\232/SQLQuery1.sql" create mode 100644 "04\351\203\221\347\216\256\345\226\206/\347\254\224\350\256\260/Note.md" diff --git "a/04\351\203\221\347\216\256\345\226\206/\344\275\234\344\270\232/SQLQuery1.sql" "b/04\351\203\221\347\216\256\345\226\206/\344\275\234\344\270\232/SQLQuery1.sql" new file mode 100644 index 0000000..e82b7ee --- /dev/null +++ "b/04\351\203\221\347\216\256\345\226\206/\344\275\234\344\270\232/SQLQuery1.sql" @@ -0,0 +1,49 @@ +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) unique check(len(userName) > 4) not null, + userSex varchar(2) not null check(userSex = '男' or userSex = '女'), + userAge int not null check(userAge >= 1 and userAge <= 100), + userAddress varchar(50) default('湖北'), + userSection int references sectionInfo(sectionID) +); + + +create table workInfo( + workId int primary key identity(1,1) not null, + userId int not null references userInfo(userNo), + workTime datetime not null, + workDescription varchar(40) not null check(workDescription = '迟到' or workDescription = '早退' or workDescription = '旷工' or workDescription = '病假' or workDescription = '事假') +); + + +insert into sectionInfo values ('营销部'); +insert into sectionInfo values ('摸鱼部'); +insert into sectionInfo values ('天龙八部'); +insert into sectionInfo values ('小卖部'); +insert into sectionInfo values ('GJ部'); +select * from sectionInfo; + + +insert into userInfo values ('列夫托尔斯','男',20,'江西',3); +insert into userInfo values ('米开朗基罗','男',19,'广东',1); +insert into userInfo values ('我带恩惠查','男',35,'福建',2); +insert into userInfo values ('分分分分的','女',19,'浙江',4); +insert into userInfo values ('哈密囧通道','女',20,'江西',5); +select * from userInfo; + + +insert into workInfo values (2,'2022-9-12 13:23','迟到'); +insert into workInfo values (4,'2022-9-12 13:23','迟到'); +insert into workInfo values (6,'2022-9-12 13:23','迟到'); +insert into workInfo values (7,'2022-9-12 13:23','迟到'); +insert into workInfo values (9,'2022-9-12 13:23','迟到'); +select * from workInfo; \ No newline at end of file diff --git "a/04\351\203\221\347\216\256\345\226\206/\347\254\224\350\256\260/Note.md" "b/04\351\203\221\347\216\256\345\226\206/\347\254\224\350\256\260/Note.md" new file mode 100644 index 0000000..ea9def0 --- /dev/null +++ "b/04\351\203\221\347\216\256\345\226\206/\347\254\224\350\256\260/Note.md" @@ -0,0 +1,38 @@ +## 鏂板缓鏁版嵁搴擄細 + +create database '鏁版嵁搴撳悕' default character set utf8 collate utf8_general_ci; + +### 鍒犻櫎鏁版嵁搴擄細 + +drop database if exists '鏁版嵁搴撳悕'; + +#### 浣跨敤鏁版嵁搴擄細 + +use 鏁版嵁搴撳悕; + +#### 鏂板缓琛細 + +create table '琛ㄥ悕' ( + +鈥 row_name 鏁版嵁绫诲瀷(闀垮害,灏忔暟鐐) unique primary key auto_increment comment '涓婚敭' + +鈥 row_name 鏁版嵁绫诲瀷(闀垮害,灏忔暟鐐) default 榛樿鍊 not null comment ''; + +鈥 foreign key(`row_name`) references `table_name`(`row_name`) + +#### 鍒犻櫎琛細 + +drop database if exists '琛ㄥ悕'; + + + +2銆佸垹闄わ細 + + delete from `table_name`; + delete from `table_name` where `row_name = values; + +## 3銆佹柊澧烇細 + + insert into `table_name` (`row_name1`,`row_name2`,...) values (value1,value2,...),(value1,value2,...); + + -- Gitee