Skip to content

Commit

Permalink
day23-24mysql数据库基础
Browse files Browse the repository at this point in the history
  • Loading branch information
rubyhan1314 committed Aug 8, 2019
1 parent 0bdff69 commit 6c4cc6d
Show file tree
Hide file tree
Showing 51 changed files with 4,234 additions and 0 deletions.
564 changes: 564 additions & 0 deletions Day23-24(MySQL数据库基础)/day23_学习笔记.md

Large diffs are not rendered by default.

1,001 changes: 1,001 additions & 0 deletions Day23-24(MySQL数据库基础)/day23_数据库基础知识和基础操作.md

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
775 changes: 775 additions & 0 deletions Day23-24(MySQL数据库基础)/day24_查询和复杂查询.md

Large diffs are not rendered by default.

Binary file not shown.
114 changes: 114 additions & 0 deletions Day23-24(MySQL数据库基础)/day24作业/作业1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
һ��������
1.student��
sno,ѧ��
sname������
sex���Ա�
dept��ϵ��
birth������
age������
phoen���绰


2.course��
cno���γ̱��
cname�������
credit��ѧ��

3.csѡ�α�
sno��ѧ��
cno���γ̱��
cj���ɼ�

������������

������ѯ
1.--��ѯ�����Ŀ��Գɼ�
select cno,cj from cs where sno=(select sno from student where sname='����
');
2.--��ѯ������ͬѧ�Ŀ��Գɼ�
select * from cs where sno in (select sno from student where sex='��');

3.--��ѯ���з�ѧ�ο��Գɼ�
select * from cs where cno=(select cno from course where cname='��ѧ')

4.--��ѯѡ��java�γ̵�ѧ������
select sname from student where sno in (select sno from cs where cno=(select cno from course where cname='JAVA'))

5.--��ѯ����80�ֵ�����ͬѧ��������ϵ��
select sname,sdept from student where sno in (select sno from cs where
cj<80);

6.--��ѯѡ��2�ſγ̲��ҿ��Գɼ���90�����ϵ�ѧ��������ѧ��
select sname,sno from student where sno in (select sno from cs where
cno = 2 and cj > 90);

7.--��ѯ��'����'��ͬһϵ��ͬѧ��Ϣ
select * from student where sdept=(select sdept from student where
sname ='����');

8.--��ѯ����ϵ�бȼ����ϵ����һ��ѧ��������С��ѧ����Ϣ
select * from student where sno in (select sno from student where sdept <>
'�����ϵ' and sage < ALL (select sage from student
where sdept = '�����ϵ'));

9.--��ѯ��Ϣϵ�б�ƽ������͵�����ѧ����Ϣ
select * from student where sdept ='��Ϣϵ' and
sage < (select avg(sage) from student);

10.--��ѯû��ѡ��3�ſγ̵�����ѧ��
select *��from student where sno not in (select sno from cs where cno = 3);




�𰸣�
1.������
��һ��student��ѧ����
CREATE TABLE student(--student
sno NUMBER(4) PRIMARY KEY,--ѧ�����
sname VARCHAR(20) NOT NULL,--ѧ������
sex VARCHAR(4) CONSTRAINT SEX CHECK (SEX='��' or sex='Ů'),--ѧ���Ա�
dept varchar(20) CONSTRAINT DEPT CHECK(DEPT IN ('��Ϣϵ','�������ѧϵ','��ѧϵ','����ϵ','����ϵ','����ϵ','��ѧϵ')),--ϵ��
brith date ,--����
age number(2) CONSTRAINT AGE CHECK (AGE BETWEEN 1 AND 100),--����
phone NUMBER(11)
)
������course���γ̱�
CREATE TABLE COURSE (--course
cno NUMBER(4) PRIMARY KEY,--�γ̱��
cname VARCHAR(20) NOT NULL,--�����
credit NUMBER(2)--ѧ��
credit
)
������cs��ѡ�α�


2.��������

INSERT INTO STUDENT VALUES (001,'����','��','��Ϣϵ','1-3��-1990',20,'13823451234');
insert into STUDENT values(002,'����','��','��ѧϵ','15-7��-1994',23,13171254631);
insert into STUDENT values(003,'����','Ů','����ϵ','3-9��-1995',22,15815674123);
insert into STUDENT values(004,'����','��','����ϵ','22-2��-1997',20,13214567125);
insert into STUDENT values(005,'����','��','��ѧϵ','26-8��-1995',22,15012387953);
insert into STUDENT values(006,'����','Ů','�������ѧϵ','26-8��-1995',22,15012567953);
insert into STUDENT values(007,'����','��','�������ѧϵ','26-8��-1995',18,15012567900);


INSERT INTO COURSE VALUES(001,'��ѧ',4);
INSERT INTO COURSE VALUES(002,'Ӣ��',2);
INSERT INTO COURSE VALUES(003,'JAVA',3);
INSERT INTO COURSE VALUES(004,'����ѧ',3);
INSERT INTO COURSE VALUES(005,'��ѧ',3);
INSERT INTO COURSE VALUES(006,'SQL',3);


INSERT INTO CS VALUES(1,3,87);
INSERT INTO CS VALUES(2,4,67);
INSERT INTO CS VALUES(5,1,66);
INSERT INTO CS VALUES(4,2,95);
INSERT INTO CS VALUES(3,3,58);
INSERT INTO CS VALUES(4,5,90);
INSERT INTO CS VALUES(1,2,90);



Binary file not shown.
5 changes: 5 additions & 0 deletions Day23-24(MySQL数据库基础)/day24作业/作业2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
--6.��ѯ���Ų���ACCOUNTING��SALES
--7.��ѯ���ʱ�20�Ų�������һ��Ա�����ߵ�Ա����Ϣ
--8.��ѯ���ʱ�20�Ų�������Ա�����ߵ�Ա����Ϣ
--9.��ѯ�����쵼��Ա�� ��Ϣ
--10.�ҵ�Ա������нˮ���ڱ�����ƽ��нˮ��Ա����
Loading

0 comments on commit 6c4cc6d

Please sign in to comment.