当前位置:网站首页>Oracle-数据库对象的使用
Oracle-数据库对象的使用
2022-07-01 13:49:00 【旷世奇才李先生】
工欲善其事必先利其器
文章持续更新,可以微信搜索【小奇JAVA面试】第一时间阅读,回复【资料】获取福利,回复【项目】获取项目源码,回复【简历模板】获取简历模板,回复【学习路线图】获取学习路线图。

一、序列
序列可以使用在数据库表的自动增长列中来用,假如我们的学生表的id想从1开始,然后自动增长,每次增加2,也就是学生id是1、3、5、7、9这种的,我们就可以配合序列来使用
序列有以下属性
sequence_name:序列名称
min_value:当前序列的最小值
max_value:当前序列的最大值
increment_by:每次序列增长的步长
cy:是否为循环序列
or:是否需要排序
cache_size:缓存个数,默认为20个
last_number:最后的数值
nextval:取得序列下一个内容,每调用一次序列的值都会增长
currval:表示取得序列的当前内容,每一次调用序列不会增长
1、创建一个序列
create sequence myseq;
2、向学生表插入一条数据,学生id使用myseq序列
insert into student(id,name) values (myseq.nextval;'张三');
3、改变myseq序列的步长,每步增加2
create sequence myseq increment by 2;
4、改变myseq序列的开始值为10000
create sequence myseq increment by 2 start with 10000;
5、创建一个循环序列,并且不使用缓存
如果我们希望某一列的数据只是1到9的数据,那么我们可以使用循环序列来操作
create sequence myseq
minvalue 1 maxvalue 9
cycle nocache;
二、同义词的作用
同义词可以将一个模式的表给另一个模式来访问。
1、将scott用户下的student表同义给sys用户使用
create sysnoym student for scott.emp;
2、将scott用户下的student表同义给所有用户使用
create public sysnoym student for scott.emp;
三、视图的定义及使用
视图是为了简化复杂查询的,视图是一张虚拟表,并不存储数据,但是数据都来源于真实表中
1、创建一个视图,从学生表中名字为‘张三’的学生中取
create view studentview as select * from student where name = '张三';
2、查询学生视图
select * from studentview;
3、更新学生视图,将name为‘张三’的年龄更新为20
update studentview set age = 20 where name = '张三';
这个时候我们发现真实表student中张三的年龄也被修改了,所以这样修改视图会影响真实表的数据,那么我们接下来创建一个视图让他修改后不影响真实表。
4、创建一个视图,从学生表中名字为‘张三’的学生中取,并且修改视图不能影响原来真实表的数据
create or replace view studentview as
select * from student where name = '张三'
with check option;
5、创建一个视图,从学生表中名字为‘张三’的学生中取,并且视图设置为只读
create or replace view studentview as
select * from student where name = '张三'
with read only;
四、索引的定义及使用
1、创建一个学生表,并给name建立索引
create index name_index on student (name);
五、总结
这里的相关内容还没有整理完毕,文章后面持续更新,建议收藏。
文章中涉及到的命令大家一定要像我一样每个都敲几遍,只有在敲的过程中才能发现自己对命令是否真正的掌握了。
可以微信搜索【小奇JAVA面试】第一时间阅读,回复【资料】获取福利,回复【项目】获取项目源码,回复【简历模板】获取简历模板,回复【学习路线图】获取学习路线图。
边栏推荐
- 2022年PMP项目管理考试敏捷知识点(6)
- El form item regular verification
- 我们该如何保护自己的密码?
- The best landing practice of cave state in an Internet ⽹⾦ financial technology enterprise
- Yan Rong looks at how to formulate a multi cloud strategy in the era of hybrid cloud
- Arthas use
- [NLP] pre training model - gpt1
- [anwangbei 2021] Rev WP
- 3.4 《数据库系统概论》之数据查询—SELECT(单表查询、连接查询、嵌套查询、集合查询、多表查询)
- 开源者的自我修养|为 ShardingSphere 贡献了千万行代码的程序员,后来当了 CEO
猜你喜欢

The best landing practice of cave state in an Internet ⽹⾦ financial technology enterprise

【机器学习】VAE变分自编码器学习笔记

进入前六!博云在中国云管理软件市场销量排行持续上升

After being laid off for three months, the interview ran into a wall everywhere, and the mentality has begun to collapse

那个很努力的学生,高考失败了……别慌!你还有一次逆袭机会!

TexStudio使用教程

Interpretation of R & D effectiveness measurement framework

2022 · 让我带你Jetpack架构组件从入门到精通 — Lifecycle

陈宇(Aqua)-安全->云安全->多云安全

App automation testing Kaiyuan platform appium runner
随机推荐
Kongsong (Xintong Institute) - cloud security capacity building and trend in the digital era
奔涌而来的数字化浪潮,将怎样颠覆未来?
受益互联网出海 汇量科技业绩重回高增长
8 best practices to protect your IAC security!
分布式事务简介(seata)
小程序- view中多个text换行
Error:Kotlin: Module was compiled with an incompatible version of Kotlin. The binary version of its
[flask] flask starts and implements a minimal application based on flask
MySQL日志
盲盒NFT数字藏品平台系统开发(搭建源码)
The integration of computing and Internet enables the transformation of the industry, and the mobile cloud lights up a new roadmap for the future of digital intelligence
面试题目总结(1) https中间人攻击,ConcurrentHashMap的原理 ,serialVersionUID常量,redis单线程,
Chen Yu (Aqua) - Safety - & gt; Cloud Security - & gt; Multicloud security
2022 · 让我带你Jetpack架构组件从入门到精通 — Lifecycle
1.8新特性-List
[NLP] pre training model - gpt1
Spark source code (V) how does dagscheduler taskscheduler cooperate with submitting tasks, and what is the corresponding relationship between application, job, stage, taskset, and task?
Summary of 20 practical typescript single line codes
2022. Let me take you from getting started to mastering jetpack architecture components - lifecycle
About fossage 2.0 "meta force meta universe system development logic scheme (details)