当前位置:网站首页>Use of Oracle database objects
Use of Oracle database objects
2022-07-01 13:58:00 【Mr. Li, a genius】
If a worker wants to do a good job, he must sharpen his tools first
Articles are constantly updated , You can search by wechat 【 Xiaoqi JAVA interview 】 First time reading , reply 【 Information 】 Access to benefits , reply 【 project 】 Get the source code of the project , reply 【 The resume template 】 Get resume template , reply 【 Learning Roadmap 】 Get a learning roadmap .

List of articles
- One 、 Sequence
- Two 、 The function of synonyms
- 3、 ... and 、 Definition and use of views
- 1、 Create a view , From the student list, the name is ‘ Zhang San ’ Of students
- 2、 Query student view
- 3、 Update student view , take name by ‘ Zhang San ’ The age of is updated to 20
- 4、 Create a view , From the student list, the name is ‘ Zhang San ’ Of students , And modifying the view cannot affect the data of the original real table
- 5、 Create a view , From the student list, the name is ‘ Zhang San ’ Of students , And the view is set to read-only
- Four 、 Definition and use of index
- 5、 ... and 、 summary
One 、 Sequence
Sequences can be used in automatic growth columns of database tables , If our students watch id Want to 1 Start , And then automatically grow , Each time 2, That is, students id yes 1、3、5、7、9 Such , We can use it with sequences
The sequence has the following properties
sequence_name: Sequence name
min_value: The minimum value of the current sequence
max_value: The maximum value of the current sequence
increment_by: The step size of each sequence increase
cy: Whether it is a cyclic sequence
or: Do you need to sort
cache_size: Number of caches , The default is 20 individual
last_number: The last value
nextval: Get the next content of the sequence , The value of the sequence increases with each call
currval: Indicates the current content of the sequence , Each call sequence will not grow
1、 Create a sequence
create sequence myseq;
2、 Insert a piece of data into the student table , Student id Use myseq Sequence
insert into student(id,name) values (myseq.nextval;' Zhang San ');
3、 change myseq The step size of the sequence , Increase every step 2
create sequence myseq increment by 2;
4、 change myseq The starting value of the sequence is 10000
create sequence myseq increment by 2 start with 10000;
5、 Create a cyclic sequence , And don't use caching
If we want a column of data to be just 1 To 9 The data of , Then we can use a cyclic sequence to operate
create sequence myseq
minvalue 1 maxvalue 9
cycle nocache;
Two 、 The function of synonyms
Synonyms can give a table of one schema to another schema to access .
1、 take scott Under the user student Table synonymous to sys The user to use
create sysnoym student for scott.emp;
2、 take scott Under the user student Table synonyms are for all users
create public sysnoym student for scott.emp;
3、 ... and 、 Definition and use of views
Views are designed to simplify complex queries , The view is a virtual table , It doesn't store data , But the data comes from real tables
1、 Create a view , From the student list, the name is ‘ Zhang San ’ Of students
create view studentview as select * from student where name = ' Zhang San ';
2、 Query student view
select * from studentview;
3、 Update student view , take name by ‘ Zhang San ’ The age of is updated to 20
update studentview set age = 20 where name = ' Zhang San ';
At this time, we found the real table student The age of Zhang San has also been revised , So changing the view in this way will affect the data of the real table , Then let's create a view so that its modification will not affect the real table .
4、 Create a view , From the student list, the name is ‘ Zhang San ’ Of students , And modifying the view cannot affect the data of the original real table
create or replace view studentview as
select * from student where name = ' Zhang San '
with check option;
5、 Create a view , From the student list, the name is ‘ Zhang San ’ Of students , And the view is set to read-only
create or replace view studentview as
select * from student where name = ' Zhang San '
with read only;
Four 、 Definition and use of index
1、 Create a student table , And give name Index
create index name_index on student (name);
5、 ... and 、 summary
The relevant contents here have not been sorted out yet , The article continues to be updated later , Recommended collection .
The commands involved in the article must be typed several times each like me , Only in the process of knocking can you find out whether you really master the command .
You can search by wechat 【 Xiaoqi JAVA interview 】 First time reading , reply 【 Information 】 Access to benefits , reply 【 project 】 Get the source code of the project , reply 【 The resume template 】 Get resume template , reply 【 Learning Roadmap 】 Get a learning roadmap .
边栏推荐
- 介绍一种对 SAP GUI 里的收藏夹事务码管理工具增强的实现方案
- 龙蜥社区开源 coolbpf,BPF 程序开发效率提升百倍
- El form item regular verification
- Applet - multiple text line breaks in view
- Yan Rong looks at how to formulate a multi cloud strategy in the era of hybrid cloud
- 奔涌而来的数字化浪潮,将怎样颠覆未来?
- Simplex, half duplex, full duplex, TDD and FDD
- A new book by teacher Zhang Yujin of Tsinghua University: 2D vision system and image technology (five copies will be sent at the end of the article)
- C language ordering management system
- Benefiting from the Internet, the scientific and technological performance of overseas exchange volume has returned to high growth
猜你喜欢
![[flask] flask starts and implements a minimal application based on flask](/img/45/77df241c85c4916914a37bb78275a5.png)
[flask] flask starts and implements a minimal application based on flask

被裁三個月,面試到處碰壁,心態已經開始崩了

【IoT毕设.上】STM32+机智云AIoT+实验室安全监控系统

leetcode622. Design cycle queue (C language)

B站被骂上了热搜。。

Several models of IO blocking, non blocking, IO multiplexing, signal driven and asynchronous IO

焱融看 | 混合云时代下,如何制定多云策略

How can we protect our passwords?

当你真的学会DataBinding后,你会发现“这玩意真香”!

Error:Kotlin: Module was compiled with an incompatible version of Kotlin. The binary version of its
随机推荐
QT learning management system
App自动化测试开元平台Appium-runner
Fiori applications are shared through the enhancement of adaptation project
How can we protect our passwords?
Admire, Ali female program undercover more than 500 black production groups
龙蜥社区开源 coolbpf,BPF 程序开发效率提升百倍
原来程序员搞私活这么赚钱?真的太香了
"National defense seven sons" funding soared, with Tsinghua reaching 36.2 billion yuan, ranking second with 10.1 billion yuan. The 2022 budget of national colleges and universities was made public
6年技术迭代,阿里全球化出海&合规的挑战和探索
学会使用LiveData和ViewModel,我相信会让你在写业务时变得轻松
2. Sensor size "recommended collection"
C语言订餐管理系统
El form item regular verification
Learning to use livedata and ViewModel will make it easier for you to write business
Journal MySQL
队列的基本操作(C语言实现)
【修复版】仿我爱看电影网站模板/海洋CMS影视系统模板
[Jianzhi offer] 55 - ii balanced binary tree
[241. Design priority for operation expression]
AnimeSR:可学习的降质算子与新的真实世界动漫VSR数据集