当前位置:网站首页>Oracle database objects
Oracle database objects
2022-07-28 21:57:00 【Xiao Lei y】
Database objects
1. Introduction to database objects
- Oracle Database objects are also called schema objects , yes Oracle The database gets components commonly used create Command to create , Use alter Command to change , use drop Delete
- Database objects are collections of logical structures , The most basic database objects are tables
- Other database objects include :
- A synonym for 2. Sequence 3. View 4. Indexes
- Common database objects are users 、 surface 、 View 、 Indexes 、 function 、 stored procedure 、 trigger 、 Sequence 、 Synonyms, etc , as well as Oracle Unique table spaces
2. A synonym for
What is a synonym
A synonym for (Synonym) Is an alias of the database object ,Oracle It can be a watch 、 View 、 Sequence 、 The process 、 function 、 Specify an alias for database objects such as packages .
The function of synonyms
A synonym is an alias for an existing object .
- simplify SQL sentence
- Hide the name and owner of the object
- Provide public access to objects
Synonym classification
There are two types of synonyms :
- Public synonyms can be accessed by all database users .
- Private synonyms can only be accessed within their schema , And cannot have the same name as the object in the current mode .
2.1 Private synonyms
Create private synonyms
- The administrator grants ordinary users the right to create private synonyms :grant create synonym to user name ;
- Create Syntax :create synonym Alias for user name . Table name

Case study :
-- to scott Tabular emp Table create private synonyms sa
create synonym sa for scott.emp;
-- Call private synonyms select * from Alias
select * from sa;
2.2 Common synonyms
Create common synonyms
- The administrator grants common users the right to create common synonyms :grant create public synonym to user name ;
- Create Syntax :create public synonym Alias for user name . Table name ;

Case study :
-- to scott Tabular emp Table create common synonyms sb
create public synonym sb for scott.emp;
-- call
-- Synonym owner select * from Alias
select * from sb;
-- Call the common synonyms of other users :
-- The common synonym owner grants the caller permission :grant all on Table name to user name ;
-- such as :
grant all on emp to sb;-- grant sb User access emp All permissions of the table ;
2.3 Delete existing synonyms
Delete synonyms
- Delete private synonyms :drop synonym user name . Synonym name ;
- Delete common synonyms :drop public synonym user name . Table name ;
When deleting common synonyms, ordinary users need to be authorized by the administrator to delete common synonyms :grant drop public synonym to user name ;
3. Sequence
- Sequences are used to generate unique 、 Objects with consecutive numbers
- The sequence can be ascending , It can also be in descending order
- Use CREATE SEQUENCE Statement to create a sequence
create sequence se_01 -- Create sequence name
start with 10 -- Set sequence from 10 Start
increment by 10 -- Set each increase 10( The interval between serial numbers is 10)
maxvalue 2000 -- Set the maximum sequence number to 2000
minvalue 10 -- Set the minimum sequence number as 10
nocycle
cache 10;
3.1 Create default sequence
- Sequence sequence: Used to generate continuous 、 Unique serial number
- Create a simple sequence : initial value =1, The incremental =1
grammar :create sequence The sequence of ;
3.2 Delete sequence
Delete sequence
- grammar :drop sequence The sequence of ;
create sequence SEQ_NO;
select SEQ_NO.NEXTVAL from dual;
select SEQ_NO.CURRVAL from dual;
insert into hrit values(SEQ_HRIT.NEXTVAL,‘john’);
select * from hrit;
3.3 Usage sequence
– Sequence name .nextval The next value is
– grammar : Sequence name .currval Current value
select seq_xxx.currval from dual;
Batch query sequence
– grammar :select The sequence of .nextval from Table name ;
select seq_xxx.nextval from emp;
Create complex sequences
– Create sequence
– grammar :create sequence The sequence of
create sequence seq_aaa
Change and delete sequences 
4. View
- View concept :
- Views display data from one or more tables in a customized manner
- Views can be thought of as “ Virtual table ” or “ Stored queries ”
- The table on which the view is created is called “ Base watch ”
- The advantages of view are :
- Provides another level of table security
- The complexity of hidden data
- Simplified user's SQL command
- Change of isolation base table structure
- By means of rebranding , Provide data from another perspective
Create view :
-- combination emp Table and dept Table to find out the name of each employee + Position + salary + Department number + Department name , And create views .
create view v_01
as
select ename,sal,job,a.deptno,dname from emp a
inner join dept b
on a.deptno=b.deptno;
Call view :select * from View name ;
5. Indexes
- To improve SQL The performance of statement execution
- Reduce disk I/O
- Use CREATE INDEX Statement to create an index
- Data that is logically and physically independent of the table
- Oracle Automatically maintain indexes
- There are various types of indexes , In addition to the standard index , There are also some special types of indexes : unique index 、 Bitmap index 、 Composite index 、 Function based index 、 Reverse key index

- Create index Syntax :create Index type index Index name a on Table name ( Name )
unique index :create unique index insex_01 on ta_01(sid);
Reverse key index
- Reverse key index reverses each byte of the key value of the index column
- Usually based on columns whose values are growing continuously , Distribute data evenly across the index
- Use... When creating an index REVERSE keyword

-- Index page : The address where the data is stored ( Indexes )
-- Data pages : Details of stored data
-- Create the appropriate index :
--a- Large amount of data
--b- Usually used for where Conditions 、 grouping 、 Index the sorted fields
create table test(
id number,
name varchar2(50)
)
select * from test where name='JACK4000000';
--Oracle Index classification :
--a- Standard index
--create index Index name on Table name ( Name );
create index ix_name on test(name);
--b- unique index , Primary key 、 Unique key automatically applies a unique index
-- create unique index Index name on Table name ( Name );
--c- Composite index , For multi condition combined query
-- create index Index name on Table name ( Name 1, Name 2...);
create index ix_name on test(name,age);
-- Delete index
--drop index Index name ;
-- Insert 5000W Data
create sequence seq_test;
truncate table test;
declare
nums number:=1;
begin
loop
insert into test values(seq_test.nextval,'JACK'||nums);
nums:=nums+1;
if nums=50000000 then
exit;
end if;
end loop;
summary
- Synonyms are aliases for existing database objects
- Sequences are used to generate unique 、 Consecutive serial numbers
- A view is a virtual table based on one or more tables
- An index is an optional structure related to a table , For improvement SQL The performance of statement execution
- Index types have standard indexes 、 unique index 、 Reverse key index 、 Bitmap index and function based index
- Index organization table accesses data based on primary key
边栏推荐
- [极客大挑战 2019]Secret File&文件包含常用伪协议以及姿势
- 株洲市九方中学开展防溺水、消防安全教育培训活动
- Detailed explanation of JVM memory layout (glory collection version)
- Open earphone which air conduction earphone with good sound quality and recognized sound quality is recommended
- 基于Paragraph-BERT-CRF的科技论文摘要语步功能信息识别方法研究
- Explain the remote debugging program of visual studio 2015 in LAN
- 针对下一代Chromebook,联发科推出新款芯片组MT8192和MT8195
- 标准C语言学习总结10
- MySQL 是如何归档数据的呢?
- openEuler Embedded SIG | 分布式软总线
猜你喜欢

kingbase中指定用户默认查找schema,或曰用户无法使用public schema下函数问题

中国科学家首次用DNA构造卷积人工神经网络,可完成32类分子模式识别任务,或用于生物标志物信号分析和诊断
![Leetcode 142. circular linked list II [knowledge points: speed pointer, hash table]](/img/74/321a4a0fab0b0dbae53b2ea1faf814.png)
Leetcode 142. circular linked list II [knowledge points: speed pointer, hash table]

Matlab | basic knowledge summary I

大学荒废三年,大四自学7个月测试,找到了12K的工作

怎样巧用断言+异常处理类,使代码更简洁!(荣耀典藏版)

LT7911D Type-C/DP转mipi 方案成熟可提供技术支持

KubeEdge发布云原生边缘计算威胁模型及安全防护技术白皮书

Implementation of sequence table

中文招聘文档中专业技能词抽取的跨域迁移学习
随机推荐
Mysql的B+树高度计算
系统分析师
KubeVela 1.4.x 官方文档
For the first time, Chinese scientists used DNA to construct convolutional artificial neural network, which can complete 32 types of molecular pattern recognition tasks, or be used for biomarker signa
Lt7911d type-c/dp to Mipi scheme is mature and can provide technical support
酷派主动终止针对小米公司的专利侵权诉讼
融合LSTM与逻辑回归的中文专利关键词抽取
Data interpolation -- normalize data of different magnitude
Save 70% of the video memory and increase the training speed by 2 times! Zheda & Ali proposed online convolution re parameterization orepa, and the code has been open source! (CVPR 2022 )
Zhuzhou Jiufang middle school carried out drowning prevention and fire safety education and training activities
Knowledge description framework of foreign patent documents based on knowledge elements
提前布局6G赛道!紫光展锐发布《6G无界 有AI》白皮书
Apifox:满足你对 Api 的所有幻想
How to skillfully use assertion + exception handling classes to make the code more concise! (glory Collection Edition)
Matlab from introduction to mastery Chapter 1 Introduction to matlab
基于多模态融合的非遗图片分类研究
日志瘦身神操作:从5G优化到1G到底是怎么做到的!(荣耀典藏版)
Hold high the two flags of 5g and AI: Ziguang zhanrui Market Summit is popular in Shencheng
What is the purpose of database read-write separation [easy to understand]
Leetcode · 581. shortest unordered continuous subarray · double pointer