📄 李建国.txt
字号:
创建表class_li
课程表(课程编号,课程名字,课程学分)
约束: 主键约束----课程编号
不为空约束---课程名字,课程学分
create table class_li
(
cid number(8) not null,
cname varchar2(20) not null,
xuefen float(4) not null,
constraint pk_cid_li primary key (cid) validate
)
创建表student_li
建一个学生选课的关系
学生表(学生号,姓名,性别,年龄,课程编号,成绩)
约束: 主键约束-----学生号;
外键约束-----课程编号,外键到课程表的课程编号
check约束----性别:值为‘男’,‘女’---- 年龄:18<age<60 ----成绩: score> 0
create table student_li
(
sid number(8) not null,
sname varchar2(20) not null,
sex char(2) not null,
age number(2) not null,
cid number(8) not null,
score float(4) not null,
constraint pk_student_li primary key (sid) validate,
constraint chk_sex_li check(sex in('男','女')) validate,
constraint chk_age_li check(age<60 and age>18) validate,
constraint fk_cid_li foreign key (cid) references class_li(cid) validate
)
给学生表 插入10行记录
给课程表插入5行记录
insert into class_li values(1,'语文',10)
insert into student_li values(1,'学生1','男',22,1,60);
把成绩〈 60分的学生成绩 + 10分,然后查下谁不及格
--select sname from (select sname,score as score1 from student_li where score<60) where score1+10<60
select * from (select * from student_li where score<60) where score+10<60
在上面的DML中 加入事务的操作,并练习下存储点的用法
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -