Databases: Fuzzy queries, views, sequences, indexes

Source: Internet
Author: User

1. Fuzzy query

Keyword "like"

% stands for any character

_ Represents a character

Like '%A ' is the last person in the name of a.

Like ' A% ' is the first character in the name of a person

Select  from where  like _b (%b)   // Query the second character in the Test1 column in the test table is B data (contains B data)

2. View

Benefits:

1) Restricting access to the database
2) Simplified Query
3) Maintain the independence of data
4) Different views can be created for the same data
5) You can delete a view without affecting the data

Create [or replace] View  as (Data to build the view)    // as after can be implemented by the SELECT statement, delete the View drop V_test Select *  from User_views                              // View data dictionary (the specific contents of the user's view) User_views is the system's table

3. Sequence

The method of constructing the sequence, which is usually used to assign a value to the primary key

CreateSequence Seq_test1//Create sequence Increment by 1                   //1start per increase with   1                   //starting position 1maxvalueTen                      //maximum value is 10minvalue1                      //minimum value is 1cycle/Nocycle//Cycle/do not cycle the cache5                          //In-memory cache of 5
Select  from dual    // querying the current value in the test1 sequence Select from dual    // Query the next value of the test1 sequence (note that viewing the next value is equivalent to using                              it) dual // system table, which contains various information about the sequence

4. Index

Improve the speed of retrieving and querying data

Create Index  on desc)  // CREATE INDEX statement (details of self-Baidu, here is not deep) Select *  from user_indexes                   // View Index

Databases: Fuzzy queries, views, sequences, indexes

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.