Oracle Getting Started fifth day (bottom)--Database other objects

Source: Internet
Author: User
Tags rollback mysql index

I. Overview

 Other database objects

  

  The main mastery is the sequence

Second, sequence

 1. What is a sequence

  Sequence: A database object that can be used by multiple users to produce unique values

Automatically provide a unique value

Shared objects

    Primarily used to provide primary key values

Loading sequence values into memory can improve access efficiency

  2. Create a sequence

CREATESEQUENCE SEQUENCE[INCREMENT by N]  --the value of each increment       [START with N]    --from which value to start       [{MAXVALUE N | Nomaxvalue}]       [{MINVALUE N | Nominvalue}]       [{CYCLE | Nocycle}]     --whether a loop is required       [{CACHE N | NOCACHE}];--whether to cache login

  There are two main ways of using the sequence:

Nextval Returns the next valid value in the sequence that any user can reference

current value of the stored sequence in the Currval

Nextval should be specified before Currval, both should be valid at the same time

SELECT  from dual;    Nextval----------       101

  To create a sequence example:

CREATEby1 with 10086  2

  Examples of Use:

INSERT  into VALUES (Emp_seq.nextval,' Xiao Ming ');

  Note : The sequence appears cracked in the following cases:

Rollback (the sequence is obsolete after rollback, no longer used)

System exceptions

Multiple tables use the same sequence at the same time

   3. View the sequence

Select  from user_sequences;

 4. Modifying the sequence

ALTER SEQUENCE dept_deptid_seq                 by  - 999999 NOCACHE               nocycle;                 

  5. Deleting a sequence

DROP SEQUENCE Dept_deptid_seq;

  for more detailed sequence use, refer to : https://www.cnblogs.com/always-online/p/4029703.html

http://blog.csdn.net/java958199586/article/details/7360152

Third, index

    1. Introduction to the Index

    

  For more index usage analysis, refer to the MySQL Index Analysis section : http://www.cnblogs.com/jiangbei/p/7420136.html

   2. Create an index

CREATE INDEX Index  on Table (column[, Column]...);

  Note: Primary keys and UNIQUE constraints will automatically create an index

Example:

CREATE INDEX  on EMP5 (name)

    3. View Index

SELECT     ic.index_name, Ic.column_name,    ic.column_position col_pos,ix.uniquenessfrom     User_indexes IX, User_ind_columns ICWHERE    =  ix.index_name and    ='EMPLOYEES';

    4. Deleting an index

DROP INDEX index;
iv. synonyms synonym

  Create:

CREATE [public] synonym synonym  for    Object

Example:

CREATE  for employees;

 Delete:

DROP Synonym D_sum;

Oracle Getting Started fifth day (bottom)--Database other objects

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.