当前位置:网站首页>不得不会的Oracle数据库知识点(三)
不得不会的Oracle数据库知识点(三)
2022-07-04 00:33:00 【zhulin1028】
目录
锁和数据库对象
1.锁
数据库用来控制共享资源并发访问的机制。
锁的类型:行级锁,表级锁。
行级锁:对正在被修改的行进行锁定。行级锁也被称之为排他锁。
在使用下列语句时,Oracle会自动应用行级锁:
insert,update,delete,select…… for update
select……for update允许用户一次锁定多条记录进行更新。
使用commit or rollback释放锁。
表级锁:
lock table user_tbl in mode mode;表级锁类型:
行共享 row share
行排他 row exclusive
共享 share
共享行排他 share row exclusive
排他 exclusive
死锁:两个或两个以上的事务相互等待对方释放资源,从而形成死锁
2.数据库对象
oracle数据库对象又称模式对象
数据库对象是逻辑结构的集合,最基本的数据库对象是表
数据库对象:
表,序列,视图,索引。
序列用于生成唯一,连续序号的对象。
创建语法:
create sequence user_id_seq
start with 1000
increment by 1
maxvalue 2000
minvalue 1000
nocycle
cache 1000;--指定内存中预先分配的序号访问序列:
select user_id_seq.currval from dual;
select user_id-seq.nextval from dual;更改删除序列:
alter sequence user_id_seq maxvalue 10000;--不能修改其start with 值
drop sequence user_id_seq;在Hibernate中访问序列:
<generator class="sequence">
<param name="sequence">
user_id_seq
</param>
</generator>视图
以经过定制的方式显示来自一个或多个表的数据
创建视图:
create or replace view
user_tbl_view (vid,vname,vage)
as select id,user_name,age from user_tbl
[with check option]|[with read only];创建带有错误的视图:
create force view user_tbl_force_view as
select * from user_table;--此时user_table可以不存在创建外联接视图:
create view user_stu_view as
select u.id,u.user_name,u.password,s.ddress
from user_tbl u,stu_tbl s
where u.s_id(+)=s.id;--哪一方带有(+),哪一方就是次要的删除视图:
drop user_stu_view;索引用于提高SQL语句执行的性能
索引类型:
唯一索引,位图索引,组合索引,基于函数的索引,反向键索引
创建标准索引:
create index user_id_index on user_tbl(id) tablespace schooltbs;重建索引:
alter index user_id_index rebuild;删除索引:
drop index user_id_index;创建唯一索引:
create unique index user_id_index on user_tbl(id);创建组合索引:
create index name_pass_index on user_tbl(user_name,password);创建反向键索引:
create index user_id_index on user_tbl(id) reverse;边栏推荐
- Kubedl hostnetwork: accelerating the efficiency of distributed training communication
- Stock price forecast
- From functional testing to automated testing, how did I successfully transform my salary to 15K +?
- CSP window
- Cannot build artifact 'test Web: War expanded' because it is included into a circular depend solution
- [C language] break and continue in switch statement
- 【leetcode】300. Longest increasing subsequence (dynamic programming, dichotomy)
- What does redis do? Redis often practices grammar every day
- For loop
- It is forbidden to splice SQL in code
猜你喜欢

Briefly understand the operation mode of developing NFT platform

Introducing Software Testing

Analysis: misunderstanding of choosing WMS warehouse management system

SPI based on firmware library

Test the influence of influent swacth on the electromagnetic coil of quartz meter

BBS forum recommendation

I wrote a chat software with timeout connect function

Cannot build artifact 'test Web: War expanded' because it is included into a circular depend solution

Tencent interview: can you find the number of 1 in binary?

Pytorch learning notes 5: model creation
随机推荐
MySQL is installed as a Windows Service
I wrote a chat software with timeout connect function
Gossip about redis source code 75
leetcode-43. String multiplication
Is it really possible that the monthly salary is 3K and the monthly salary is 15K?
[BSP video tutorial] stm32h7 video tutorial phase 5: MDK topic, system introduction to MDK debugging, AC5, AC6 compilers, RTE development environment and the role of various configuration items (2022-
Celebrate the new year | Suihua fire rescue detachment has wonderful cultural activities during the Spring Festival
How to be a professional software testing engineer? Listen to the byte five year old test
Iclr2022: how does AI recognize "things I haven't seen"?
Tencent interview: can you pour water?
P3371 [template] single source shortest path (weakened version)
Investment demand and income forecast report of China's building ceramics industry, 2022-2028
Solve the problem that the kaggle account registration does not display the verification code
NLP pre training technology development
Double efficiency. Six easy-to-use pychar plug-ins are recommended
Private project practice sharing populate joint query in mongoose makes the template unable to render - solve the error message: syntaxerror: unexpected token r in JSON at
Global and Chinese markets for blood and liquid heating devices 2022-2028: Research Report on technology, participants, trends, market size and share
Data storage - interview questions
Gossip about redis source code 83
From functional testing to automated testing, how did I successfully transform my salary to 15K +?