📄 田粟.txt
字号:
建一个学生选课的关系
学生表(学生号,姓名,性别,年龄,课程编号,成绩)
约束: 主键约束-----学生号;
外键约束-----课程编号,外键到课程表的课程编号
check约束----性别:值为‘男’,‘女’---- 年龄:18<age<60 ----成绩: score> 0
课程表(课程编号,课程名字,课程学分)
约束: 主键约束----课程编号
不为空约束---课程名字,课程学分
给学生表 插入10行记录
给课程表插入5行记录
把成绩〈 60分的学生成绩 + 10分,然后查下谁不及格
下午 加入 事物的练习
create table kc(kid int,kname varchar(20),kfen int);
alter table kc add constraint prm_kc_kid PRIMARY key(kid);
alter table kc modify kname not null;
SQL> alter table kc modify kfen not null;
SQL> create table xs(id int,name varchar2(20),sex char(2),age int,kid int,score int);
SQL> alter table xs add constraint pri_xs_id primary key (id);
SQL> alter table xs add constraint fk_xs_kid_kc_kid foreign key(kid) references kc (kid);
SQL> alter table xs add constraint check_xs_sex check(sex in('男','女'));
SQL> alter table xs add constraint check_xs_age check( age>18 or age<60);
SQL> alter table xs add constraint check_xs_score check( score>0);
SQL> select * from xs where score+10<60;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -