a、Oracle基础教程
Oracle教程
参考文档:
FreeIT教程
w3cschool教程
《Oracle从入门到精通(第3版) 明日科技》
目录
本篇章主要介绍Oracle的基础教程,本文适合那些刚刚要学习Oracle的初学者或者是想了解Oracle的用户,通过本篇幅可以快速学习Oracle数据库的基础理论。本文通过讲解Oracle基础理论知识,让大家快速的了解Oracle,并通过实例演示,让你更有介入感,能够快速上手,而不仅仅只保留在理论知识上。本篇章的主要内容如下:
- 1、Oracle介绍:介绍了Oracle数据库应用场景和发展历史,Oracle的平台支持,Oracle的技术特点,orale的相关体系结构。
- 2、Oracle安装:详细介绍Oracle11g安装过程,教你一步一步搭建Oracle数据库。
- 3、Oracle客户端工具:介绍Oracle客户端工具(sqlplus)如何使用和plsql developer工具应用和下载。
- 4、Oracle服务:介绍Oracle11g安装完毕后各个服务的详细作用。
- 5、Oracle用户:介绍Oracle用户的创建和用户权限、数据库角色的概念以及授权语句的编写。
- 6、Oracle表介绍:介绍Oracle表的创建、查询、插入、更新、删除操作。
- 7、Oracle运算符介绍:介绍Oracle运算符的运用,其中算术运算、关系和逻辑运算符的实际应用。
- 8、Oracle系统关键字:如Oracle字符串连接符||、DISTINCT去重符、Oracle条件查询中的=、in、like、between...and等。
- 9、Oracle集合运算:Oracle集合运算就是把多个查询结果组合成一个查询结果,oralce的集合运算包括:INTERSECT(交集)、UINION ALL(交集不重复)、UINION(交集)、MINUS(补集)。
- 10、Oracle连接查询:oralce连接查询是用来进行表间关联的,包含内关联(inner jion )和外关联(outer join),其中外关联又分为左外关联(left outer join)、右外关联(right outer join)和全外连接(full join),其中外关联可以使用(+)来表示。
- 11、Oracle伪列:rowid、rownum。它们是Oracle表在存储的过程中或查询的过程中,表会有一些附加列,称为伪列。伪列就像表中的字段一样,但是表中并不存储。伪列只能查询,不能增删改。
- 12、Oracle内置函数:Oracle内置函数包括Oracle字符型函数、Oracle日期函数、Oracle数值型函数、Oracle转换函数、Oracle聚合函数的介绍。
- 13、Oracle子查询:Oracle子查询就是嵌套查询,他把select 查询的结果作为另外一个select、update或delete语句的条件,它的本质就是where条件查询中的一个条件表达式。
- 14、Oracle同义词:Oracle synonym 同义词是数据库当前用户通过给另外一个用户的对象创建一个别名,然后可以通过对别名进行查询和操作,等价于直接操作该数据库对象。
- 15、Oracle序列:Oracle序列Sequence是用来生成连续的整数数据的对象,它经常用来作为业务中无规则的主键。Oracle序列可以是升序列也可以是降序列。
- 16、Oracle视图:oracle视图可以理解为数据库中一张虚拟的表,他是通过一张或者多张基表进行关联查询后的结果组成一个虚拟的表。查询视图,本质上是对表进行关联查询。
- 17、Oracle索引:Oracle索引(index)最大的作用是来优化数据库查询的效率,提升数据库的查询性能。就好比书的目录一样,可以通过目录来直接定位所需内容存在的页数,大大提高检索效率。
案例所需表结构
该Oracle基础教程所有案例所需的表结构是利用Oracle技术圈自己设计的一套简单版的学生信息系统的表结构。相关表结构的关系图如下:
表结构执行脚本:
-- Create table
create table STUINFO
(
stuid VARCHAR2(11) not null,
stuname VARCHAR2(50) not null,
sex CHAR(1) not null,
age NUMBER(2) not null,
classno VARCHAR2(7) not null,
stuaddress VARCHAR2(100) default '地址未录入',
grade CHAR(4) not null,
enroldate DATE,
idnumber VARCHAR2(18) default '身份证未采集' not null
)
tablespace USERS
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
-- Add comments to the table
comment on table STUINFO
is '学生信息表';
-- Add comments to the columns
comment on column STUINFO.stuid
is '学号';
comment on column STUINFO.stuname
is '学生姓名';
comment on column STUINFO.sex
is '学生性别';
comment on column STUINFO.age
is '学生年龄';
comment on column STUINFO.classno
is '学生班级号';
comment on column STUINFO.stuaddress
is '学生住址';
comment on column STUINFO.grade
is '年级';
comment on column STUINFO.enroldate
is '入学时间';
comment on column STUINFO.idnumber
is '身份证号';
-- Create/Recreate primary, unique and foreign key constraints
alter table STUINFO
add constraint PK_STUINFO primary key (STUID)
using index
tablespace USERS
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
-- Create table
create table CLASS
(
classno VARCHAR2(7) not null,
classname VARCHAR2(50),
monitorid VARCHAR2(11),
monitorname VARCHAR2(50),
headmasterid VARCHAR2(8),
headmastername VARCHAR2(50),
classaddress VARCHAR2(50),
enterdate DATE
)
tablespace USERS
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
-- Add comments to the table
comment on table CLASS
is '班级信息表';
-- Add comments to the columns
comment on column CLASS.classno
is '班级号';
comment on column CLASS.classname
is '班级名称';
comment on column CLASS.monitorid
is '班长学号';
comment on column CLASS.monitorname
is '班长姓名';
comment on column CLASS.headmasterid
is '班主任教师号';
comment on column CLASS.headmastername
is '班主任姓名';
comment on column CLASS.classaddress
is '班级地址';
comment on column CLASS.enterdate
is '录入时间';
-- Create/Recreate primary, unique and foreign key constraints
alter table CLASS
add constraint PK_CLASS primary key (CLASSNO)
using index
tablespace USERS
pctfree 10
initrans 2
maxtrans 255;
-- Create table
create table COURSE
(
courseid VARCHAR2(9) not null,
schyear VARCHAR2(4),
term VARCHAR2(4),
coursename VARCHAR2(100)
)
tablespace USERS
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
-- Add comments to the table
comment on table COURSE
is '课程表';
-- Add comments to the columns
comment on column COURSE.courseid
is '课程id';
comment on column COURSE.schyear
is '学年';
comment on column COURSE.term
is '学期';
comment on column COURSE.coursename
is '课程名称';
-- Create/Recreate primary, unique and foreign key constraints
alter table COURSE
add constraint PK_COURSE primary key (COURSEID)
using index
tablespace USERS
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
-- Create table
create table STUCOURSE
(
selectid VARCHAR2(18) not null,
stuid VARCHAR2(11),
courseid VARCHAR2(9),
schyear VARCHAR2(4),
term VARCHAR2(4),
redo VARCHAR2(1),
selectdate DATE
)
tablespace USERS
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
-- Add comments to the table
comment on table STUCOURSE
is '学生选课表';
-- Add comments to the columns
comment on column STUCOURSE.selectid
is '选课id';
comment on column STUCOURSE.stuid
is '学号';
comment on column STUCOURSE.courseid
is '课程id';
comment on column STUCOURSE.schyear
is '年度';
comment on column STUCOURSE.term
is '学期';
comment on column STUCOURSE.redo
is '是否重修';
comment on column STUCOURSE.selectdate
is '选课时间';
-- Create/Recreate primary, unique and foreign key constraints
alter table STUCOURSE
add constraint PK_STUCOURSE primary key (SELECTID)
using index
tablespace USERS
pctfree 10
initrans 2
maxtrans 255;
-- Create table
create table SCORE
(
scoreid VARCHAR2(18) not null,
stuid VARCHAR2(11),
courseid VARCHAR2(9),
score NUMBER,
scdate DATE
)
tablespace USERS
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
-- Add comments to the table
comment on table SCORE
is '学生成绩表';
-- Add comments to the columns
comment on column SCORE.scoreid
is '学生成绩id';
comment on column SCORE.stuid
is '学生学号';
comment on column SCORE.courseid
is '课程id(年度+上下学期+课程序列)';
comment on column SCORE.score
is '成绩';
comment on column SCORE.scdate
is '成绩录入时间';
-- Create/Recreate primary, unique and foreign key constraints
alter table SCORE
add constraint PK_SCORE primary key (SCOREID)
using index
tablespace USERS
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?