声明: 本文仅为个人总结,并非基础教程,主要通过实例问题来总结数据库sql的思想,遇到的问题以及解决方案,本人也是菜鸟,如有不足之处,还请多多指教。
首先 ,
实例数据库的建立,包括 teacher表,student表,sc表,course表,不再多说
teacher表
create table TEACHER
(
TID VARCHAR2(32),
TNAME VARCHAR2(32)
)
teacher表插入数据
insert into teacher values ('001','姚明');
insert into teacher values ('002','叶平');
insert into teacher values ('003','叶开');
insert into teacher values ( '004','孟星魂');
insert into teacher values ('005','独孤求败');
insert into teacher values ('006','裘千仞');
insert into teacher values ('007','裘千尺');
insert into teacher values ('008','赵志敬');
insert into teacher values ('009','阿紫');
insert into teacher values ('010','郭芙蓉');
insert into teacher values ('011','佟湘玉');
insert into teacher values ('012','白展堂');
insert into teacher values ('013','吕轻侯');
insert into teacher values ('014','李大嘴');
insert into teacher values ('015','花无缺');
insert into teacher values ('016','金不换');
insert into teacher values ('017','乔丹');
course表
create table COURSE
(
CID VARCHAR2(32),
CNAME VARCHAR2(32),
TID VARCHAR2(32)
)
course表插入数据
insert into course values('001','企业管理','002');
insert into course values( '002','马克思','008');
insert into course values( '003','UML','006');
insert into course values( '004','数据库','007');
insert into course values('005','逻辑电路','006');
insert into course values('006','英语','003');
insert into course values('007','电子电路','005');
insert into course values( '008','毛泽东思想概论','004');
insert into course values('009','西方哲学史','012');
insert into course values('010','线性代数','017');
insert into course values('011','计算机基础','013');
insert into course values('012','AUTO CAD制图','015');
insert into course values('013','平面设计','011');
insert into course values('014','Flash动漫','001');
insert into course values('015','Java开发','009');
insert into course values('016','C#基础','002' );
insert into course values('017','Oracl数据库原理','010');
student表
Create table Student (
sid varchar2(32),--学号
sname varchar2(32),--学生姓名
sage number,--学生年龄
ssex varchar(2)--学生性别
);
student表插入数据
insert into Student values('1000','张无忌',18,'男');
insert into Student values('1001','周芷若',19,'女');
insert into Student values('1002','杨过',19,'男' );
insert into Student values('1003','赵敏',18,'女');
insert into Student values('1004','小龙女',17,'女' );
insert into Student values('1005','张三丰',18,'男');
insert into Student values('1006','令狐冲',19,'男');
insert into Student values('1007','任盈盈',20,'女');
insert into Student values('1008','岳灵珊',19,'女');
insert into Student values( '1009','韦小宝',18,'男');
insert into Student values ('1010','康敏',17,'女');
insert into Student values('1011','萧峰',19,'男');
insert into Student values ('1012','黄蓉',18,'女');
insert into Student values ('1013','郭靖',19,'男');
insert into Student values ('1014','周伯通',19,'男');
insert into Student values('1015','瑛姑',20,'女');
insert into Student values ('1016','李秋水',21,'女');
insert into Student values('1017','黄药师',18,'男');
insert into Student values('1018','李莫愁',18,'女');
insert into Student values('1019','冯默风',17,'男');
insert into Student values('1020','王重阳',17,'男');
insert into Student values('1021','郭襄',18,'女');
sc表
create table sc(
sid varchar2(32),--学号
cid varchar2(32),--课程编号
score number--成绩
);
sc表插入数据
insert into sc values( '1001','003',90);
insert into sc values('1001','002',87);
insert into sc values('1001','001',96);
insert into sc values( '1001','010',85);
insert into sc values( '1002','003',70 );
insert into sc values('1002','002',87);
insert into sc values('1002','001',42);
insert into sc values( '1002','010',65 );
insert into sc values('1003','006',78 );
insert into sc values('1003','003',70 );
insert into sc values( '1003','005',70);
insert into sc values( '1003','001',32);
insert into sc values('1003','010',85 );
insert into sc values('1003','011',21);
insert into sc values( '1004','007',90);
insert into sc values('1004','002',87);
insert into sc values( '1005','001',23);
insert into sc values('1006','015',85);
insert into sc values('1006','006',46);
insert into sc values('1006','003',59);
insert into sc values( '1006','004',70);
insert into sc values('1006','001',99);
insert into sc values('1007','011',85);
insert into sc values('1007','006',84);
insert into sc values('1007','003',72);
insert into sc values('1007','002',87);
insert into sc values('1008','001',94);
insert into sc values( '1008','012',85);
insert into sc values('1008','006',32);
insert into sc values( '1009','003',90);
insert into sc values('1009','002',82);
insert into sc values('1009','001',96);
insert into sc values('1009','010',82);
insert into sc values('1009','008',92);
insert into sc values('1010','003',90);
insert into sc values('1010','002',87);
insert into sc values('1010','001',96);
insert into sc values('1011','009',24);
insert into sc values('1011','009',25);
insert into sc values( '1012','003',30);
insert into sc values('1013','002',37);
insert into sc values('1013','001',16);
insert into sc values('1013','007',55);
insert into sc values('1013','006',42 );
insert into sc values('1013','012',34 );
insert into sc values('1000','004',16 );
insert into sc values('1002','004',55);
insert into sc values('1004','004',42);
insert into sc values( '1008','004',34);
insert into sc values('1013','016',86);
insert into sc values('1013','016',44);
insert into sc values('1000','014',75);
insert into sc values('1002','016',100);
insert into sc values('1004','001',83 );
insert into sc values('1008','013',97);