Java:oracle (view, index, sequence)

Source: Internet
Author: User

1. Index: The index is divided into 4 kinds

-In Oracle,
--Normal: Normal index
-Unique: Unique index
--Bitmap: Bitmap index
--B-Tree index: Default: Oracle automatically adds a B-tree index to each column if no index is established

--Index (subscript, index): As indexes, in Oracle if the index can meet the current query requirements, only need to build an index, Oracle's own mechanism will help you to use
--If the current query Oracle comes with an index that is not sufficient, you should write your own index (do not learn)
--the index can be directly understood as a directory

--Two fork tree: can have multiple layers, but each layer has a maximum of two nodes
--but B-tree: There can also be layers, but each layer can have multiple nodes
  

 --under what circumstances will index lookups be enabled?
--If a where (conditional query) exists, the index must be started
--All index classifications do not belong to (for) a table, but are applicable to a column

  

 --Normal: Normal index
--is equivalent to a normal field
--Normal,unique index operation mechanism: He will add a subscript to the bound column, and once the indexed column is used in where, the index is automatically started, the description is first found, all the subscript is listed, the subscript is compared, if found, return to the bar data, and returns NULL if it is not found
SELECT * FROM classes where description = ' Java basics ';

 

-Unique: Unique index
--Index bound column data cannot have any duplicates, but can be null, the unique index is mainly used for primary key ID, regional table, National table, Urban table, Social Security number
--Automatically establishes a unique index when a table's primary key and unique key are established

 

--B-Tree index: like a two-fork tree, but a binary tree can have only two nodes, but a B-tree may have multiple nodes

  

  --Bitmap: Bitmap index
--How?
Take gender as an example: the male Mark 1, the female is marked as 0, in the search, will be gender conversion to digital, (such as query all for male user information), and 1,0 to compare, if 1 all find out, if is 0 all excluded
--Bitmap Indexing scenario: There is a lot of duplicate data, and the data selectivity is very small (gender, marital no, whether adult ...) )

  

2. View:

  --View (view): Virtual table (requires real table to provide data)
--Visualize images
--The Oracle view is virtual non-existent and is not stored on the hard disk
    --View mechanism : data stored in the view through a real table map, the entire process of mapping in memory, so the query view is faster than querying the real table
    --The benefits of the view : The first query speed, the second does not occupy any hard disk space, the third can be very good for the need for confidential data processing

 

  --The view is to solve:
--First: Information security issues
--Second: query efficiency issues
--Third: Convenient query

 

--How to create a view?   
--Find the Views folder, click New-->name: The name of the view, item List: Column name, table list: Tables name of the table-based view, WHERE clause: throttling conditions 
--Building the view:
--If you need to change the view data, but do not need to replace the view name or replace
--whether it is a timer, PL/SQL, view, stored procedure create or replace
CREATE View Test_views as (SELECT * from classes);
Create or Replace view test_views as (SELECT * from classes);
--WHERE clause: limiting conditions
CREATE View Test_views2 as (SELECT * from teacher) with Read only;
select * from Test_views;
select * from teacher;


--! =,==,<=,>=,<,>: The corresponding English:   
Create or Replace view Lt_one_thround_five_hundrand as (select Tor.total_price prices, Tut.type_name, Tur.username F Rom T_order Tor
INNER JOIN T_user tur on tur.id = tor.user_id
INNER join T_user_type tut on tut.id = tur.user_type_id where Tor.total_price >);

select * from Lt_one_thround_five_hundrand;

3. Sequence: Sequence

Concept:

Ordered queue (arithmetic progression, geometric series.): First in a certain order, the second is to form a queue
The so-called Oracle sequence, the most commonly used is the self-increment primary key

  In PL/SQL, there is a folder called sequences, and what is stored in this folder is called a sequence.

  

 How to create a sequence:
    name : The name of the sequence (can be arbitrarily named)
    start at : where this sequence starts
    Increment: number of increments per increment
    Minimum Value: The smallest number you define, with the primary key ID as an example, to limit the range of IDs
The same maximum value is the same as the minimum value.
When creating a sequence, if there is no special requirement, only one name is required, and the other values have default values.
When the default value is used, the value starting from this column starts at 0 (the current value)

  

  When querying a sequence, there are two properties: Nextval,currval
--Nextval:next value Next
--Currval:current value current values
Use the Select Sequence name. property name from dual; To query the value of a sequence
  

  Oracle rules that when querying a sequence for the first time, be sure to use Nextval, because the sequence also needs to be initialized
In the sequence, the increment of the number is controlled by the increment.

  Sequence: The most important scenario is the self-increment of the primary key in Oracle
If you use the self-increment ID for this scenario, the sequence needs only one name, and no property values need to be modified

  

4.Other:

Algorithm first to learn data structure
Algorithm analysis: sin cos tan cotan matrix Lagrange naive Bayesian genetic algorithm
Introduction to Algorithms

--Package: is a bundle in Java
--it's the same folder where you categorize files.
--Java in the package below can be class,interface,package,xml ...
--In the real development environment: cars.class-->entity (Entity), Operation database Class-->dao, business logic Layer--->service, the query data is to be uploaded to the page to display--->control Ler, Tool class--->util, filter--->filter,interceptor (Interceptor)--->interceptor
--Model View Controller--->MVC
INSERT into teacher (ID, name, age, description, hire_date) VALUES (s_teacher_id.nextval, ' hehehe ', 17, ' Test data ', sysdate);

Java:oracle (view, index, sequence)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.