Oracle built-in objects
sequence , view, index
sequence
create sequence aaa start with 1;
use the
view
to create it and
then use
it directly.
With view, you can replace the subquery, making the sql concise
. The view stores not the real data, but the query statement
The base table can be modified through the view. The
premise is that the data structure of the view must be the same as the data structure of the base table!
Read-only view
But the view is for viewing, not for modifying.
So how can you prevent modification operations later when you create a view? The answer is as follows:
Check the view
There is another situation, if you want to modify the view, then the view column itself is not constrained, then adding the check view, you can go to the base table to check the constraints The
above are simple views
and multi- table join queries The result is a complex view that can only be used to simplify queries.
Note : Views can be used wherever tables can be used!
Finally to the index!
The role
of Interview questions: How to query massive data fast: index + optimization
OK, let's learn indexes
When we create constraints for columns, some constraints automatically create indexes for us There
are many kinds of indexes, which are automatically added above It is called a unique value index.
Next , we build our own index, which is called a common index.
Single field index:
Multi-field index
In fact , the index is a table, just like the directory of a book, query things can be quickly located, and you don't have to look for it page by page.
In addition, the index is based on the hard disk and memory space of the database, which is the so-called consumption of resources in exchange for speed
. The most important thing is that after adding an index to a field, it can be exchanged for a faster speed, but at the same time, it will reduce the speed of additions, deletions and changes, because adding an index When deleting and modifying operations, the index table will be updated, which is equivalent to twice the speed!
The index table is automatically maintained by the database for us, and we do not need to maintain it ourselves. This is another biggest benefit of indexing.
Special Index: Bitmap Index
There is a situation where the data of some columns created only have a few types of data, such as
gender: only male and female Classes in the student table of
a school: only first grade, second grade to sixth grade
, so you want to quickly locate these Data, for example, I want to check the information of the second graders among the 100,000 students in a school,
then we need a special index called bitmap index.
When I query
this sentence, it will quickly
add index rules, only Commonly used where-limited columns are indexed. For
example I want to frequently check the time period, that is, the time period is defined in where, then we add an index to the time column.
Sequence, view, index (go for the interview)
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326377770&siteId=291194637
Recommended
Ranking