📄 段湘南.txt
字号:
学生表:
creat table student_010(id number(4),name varchar2(20),sex char(2),age int,coid number(2), score float(4));
课程表:
create table course_010(coid number(2),coname varchar2(20),comark number(2));
主键约束----课程编号:
alter table course_010 add constraint pri_co_coid primary key(coid);
不为空约束---课程名字,课程学分:
alter table course_010 modify coname not null;
alter talbe course_010 modify comark not null;
主键约束-----学生号:
alter table student_010 add constraint pri_stu_id primary key(id);
外键约束-----课程编号,外键到课程表的课程编号:
alter talbe student_010 add constraint fk_stu_coid_co_coid foreign key(coid)
references course_010(coid);
check约束----性别:值为‘男’,‘女’---- 年龄:18<age<60 ----成绩: score> 0:
alter table student_010 add constraint check1_sex check(sex in('男','女'));
alter table student_010 add constraint check1_age check(age between 18 and 60);
alter table student_010 add constraint check2_score check(score>0);
给学生表 插入10行记录
给课程表插入5行记录:
ID NAME SEX AGE COID SCORE
----- -------------------- --- --------------------------------------- ---- ------
1002 Jacky 男 19 10 70
1003 John 男 25 30 54
1004 Micky 女 18 20 84
1005 Lucy 女 22 50 44
1006 Dicky 男 24 50 94
1007 Tom 男 34 40 34
1008 Lili 女 24 30 50
1009 ann 女 30 10 49
1010 Clin 女 20 50 69
1011 Dom 男 60 20 79
COID CONAME COMARK
---- -------------------- ------
10 math 4
20 english 3
30 history 2
40 physics 4
50 chemistry 4
把成绩〈 60分的学生成绩 + 10分,然后查下谁不及格:
select id,name,score from student_010 where score + 10 < 60;
ID NAME SCORE
----- -------------------- ------
1005 Lucy 44
1007 Tom 34
1009 ann 49
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -