From e698eec61fe05e8135705cc16dfdcad8e74b40e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=AD=A3=E8=B1=AA?= Date: Fri, 16 Sep 2022 04:40:30 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20=E5=BC=A0=E6=AD=A3?= =?UTF-8?q?=E8=B1=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\345\274\240\346\255\243\350\261\252/.keep" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "\345\274\240\346\255\243\350\261\252/.keep" diff --git "a/\345\274\240\346\255\243\350\261\252/.keep" "b/\345\274\240\346\255\243\350\261\252/.keep" new file mode 100644 index 0000000..e69de29 -- Gitee From f7108fa6d15acb9362c99db815fdb4a067e37f76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=AD=A3=E8=B1=AA?= Date: Fri, 16 Sep 2022 04:53:19 +0000 Subject: [PATCH 2/2] =?UTF-8?q?37=E5=BC=A0=E6=AD=A3=E8=B1=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张正豪 --- .../\344\275\234\344\270\232/SQLQuery1.sql" | 33 +++++++++++++++++++ .../\347\254\224\350\256\260.txt" | 20 +++++++++++ 2 files changed, 53 insertions(+) create mode 100644 "\345\274\240\346\255\243\350\261\252/22-09-16\345\274\240\346\255\243\350\261\252/\344\275\234\344\270\232/SQLQuery1.sql" create mode 100644 "\345\274\240\346\255\243\350\261\252/22-09-16\345\274\240\346\255\243\350\261\252/\347\254\224\350\256\260/\347\254\224\350\256\260.txt" diff --git "a/\345\274\240\346\255\243\350\261\252/22-09-16\345\274\240\346\255\243\350\261\252/\344\275\234\344\270\232/SQLQuery1.sql" "b/\345\274\240\346\255\243\350\261\252/22-09-16\345\274\240\346\255\243\350\261\252/\344\275\234\344\270\232/SQLQuery1.sql" new file mode 100644 index 0000000..d37b02d --- /dev/null +++ "b/\345\274\240\346\255\243\350\261\252/22-09-16\345\274\240\346\255\243\350\261\252/\344\275\234\344\270\232/SQLQuery1.sql" @@ -0,0 +1,33 @@ +create database DBTEST; +use DBTEST; +create table sectionInfo( + sectionID int primary key identity(1,1), + sectionName varchar(10) not null +); +insert sectionInfo(sectionName) values (''),(''),('ڲ'),('Ӫ'),('߻'); + +create table userInfo( + userNo int primary key not null identity(1,1), + userName varchar(10) not null check(len(userName)>4) unique, + 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('','',30,'',2),('','',20,'',2), +('Ŵ','Ů',22,'',3),('ܷ','',25,'',5),('','',26,'',3); + + +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-09-10 03:59:00',''),(2,'2022-09-11 21:33:23','¼'), +(3,'2022-09-11 19:29:38',''),(4,'2022-09-13 17:29:11','ٵ'),(5,'2022-09-15 08:08:08',''); + +select * from sectionInfo; +select * from userInfo; +select * from workInfo; \ No newline at end of file diff --git "a/\345\274\240\346\255\243\350\261\252/22-09-16\345\274\240\346\255\243\350\261\252/\347\254\224\350\256\260/\347\254\224\350\256\260.txt" "b/\345\274\240\346\255\243\350\261\252/22-09-16\345\274\240\346\255\243\350\261\252/\347\254\224\350\256\260/\347\254\224\350\256\260.txt" new file mode 100644 index 0000000..fed4d04 --- /dev/null +++ "b/\345\274\240\346\255\243\350\261\252/22-09-16\345\274\240\346\255\243\350\261\252/\347\254\224\350\256\260/\347\254\224\350\256\260.txt" @@ -0,0 +1,20 @@ +创建库:create database 库名 +使用库:use 库名 +删除库:drop database 库名 + +创建表:create table 表名() +主键:primary key +自增:identity(1,1) +默认约束:default +检查:check +长度:len +非空:not null +外键:字段名 类型 references 表(字段名) +规定长度:check(len(字段名) = 值) +范围: check(字段名 between 最小值 and 最大值) + +新增:insert 表明(字段名) values(插入数据) +查询:select + + + -- Gitee