diff --git "a/\351\231\206\345\273\272\351\224\213/.keep" "b/\351\231\206\345\273\272\351\224\213/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\351\231\206\345\273\272\351\224\213/2022-09-15\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/2022.09.15\347\232\204sql\347\254\254\344\270\200\346\254\241\347\254\224\350\256\260.txt" "b/\351\231\206\345\273\272\351\224\213/2022-09-15\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/2022.09.15\347\232\204sql\347\254\254\344\270\200\346\254\241\347\254\224\350\256\260.txt" new file mode 100644 index 0000000000000000000000000000000000000000..df356bb9d569932e32a0496711dce07e57a315c6 --- /dev/null +++ "b/\351\231\206\345\273\272\351\224\213/2022-09-15\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/2022.09.15\347\232\204sql\347\254\254\344\270\200\346\254\241\347\254\224\350\256\260.txt" @@ -0,0 +1,26 @@ +--关系型数据库:SQL server, Mysql, Oracle +--创建数据库:create database 数据库名 +--database:数据库 + --使用数据库 + use dbtest + create table 表名( + userNo int primary key identity(1,1),--员工编号 + userName varchar(10)check(len(userName)>4) unique not null,--员工姓名 + userSex varchar(2) check(userSex in('男','女'))not null,--员工性别 + userAge int not null check(userAge>=1 and userAge<=100),--员工年龄 + userAddress varchar(50) default('湖北'),--员工地址 + userSection int references sectioninfo(sectionID)--员工部门 +) +--check;核查 UNIQUE;唯一约束 +--default:默认约束 +--references ;外键 + + --插入数据: insert [into] 表名(字段名) values(值) + insert into ClassInfo( ClassName) values('软件1班'); + + --增加外键 + --修改表结构 表名 add constraint 约束名 foreign key(要引用的字段) references 主键表(字段) + Alter table StuInfo add constraint FK_StuInfo_ClassId foreign key(ClassID) references ClassInfo(ClassID) + + --新增姓名列 + alter table StuInfo add stuName varchar(20) \ No newline at end of file diff --git "a/\351\231\206\345\273\272\351\224\213/2022-09-15\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/SQLQuery1.sql" "b/\351\231\206\345\273\272\351\224\213/2022-09-15\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/SQLQuery1.sql" new file mode 100644 index 0000000000000000000000000000000000000000..aa587bba3ece7a678412a9669613be5889095513 --- /dev/null +++ "b/\351\231\206\345\273\272\351\224\213/2022-09-15\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/SQLQuery1.sql" @@ -0,0 +1,38 @@ +--ݿ +create database DBTEST + +--ʹݿ +use DBTEST + +-- sectioninfo +create table sectioninfo( + sectionID int primary key identity(1,1),--ű + sectionName varchar(10) not null-- +); +insert into sectioninfo( sectionName) values('Ʒ'),('Դ'),(''),('ڲ'),('ͻ') + +--ԱϢ userinfo +create table userinfo( + userNo int primary key identity(01,1),--Ա + --check;˲ UNIQUE;ΨһԼ + userName varchar(10)check(len(userName)>4) unique not null,--Ա + --default:ĬԼ + userSex varchar(2) check(userSex in('','Ů'))not null,--ԱԱ + userAge int not null check(userAge>=1 and userAge<=100),--Ա + userAddress varchar(50) default(''),--Աַ + --references ; + userSection int references sectioninfo(sectionID)--Ա +); +insert into userinfo(userName,userSex,userAge,userAddress,userSection) +values('111','','25','㶫','1'),('210','','25','','1'),('С111','Ů','24','','2'), +('111','','25','㶫','1'),('111','','25','㶫','2') + +--Աڱ +create table workinfo( + workID int primary key identity(1001,1),--ڱ + userID int references userinfo(userNO),--Ա + workTime datetime not null,--ʱ + workDescription varchar(40) not null check(workDescription in('ٵ','','','','¼'))--˵ +); +insert into workinfo(userID,workTime,workDescription)values('01','2022-09-15','ٵ'),('02','2022-09-15','ٵ'), +('03','2022-09-15','ٵ'),('04','2022-09-15','ٵ'),('05','2022-09-15','ٵ') \ No newline at end of file