[1 Moss per day]-[sequence]-continued-RAC and Sequences (853652.1)

Source: Internet
Author: User

[One Moss per day]-[sequence]-continued-RAC and Sequences (853652.1) [one Moss per day]-RAC and Sequences (853652.1) http://www.bkjia.com/database/201308/239400.html what can be said of a simple sequence? If this is the case, it would be a big mistake... Some of the following high people may be very clear, but at least for me, they were unfamiliar or ignored. 1. create sequence seq; without any parameters, the default SQL statement is:

-- Create sequence create sequence SEQminvalue 1maxvalue 999999999999999999999999999start with 21increment by 1cache 20;

 

Start with is 21, increment by is 1, and cache is 20. Master Huang Yong explained that "Looks like the reverse-engineered sequence definition takes" start with "(1 by default) as" start with "value before the sequence is ever used, but takes "increment by" x "cache" + "start with" after it's used once or a few times. "Before the sequence is used, the sequence uses" start with (1 by default) "as the starting point. After one or several times of use, the sequence uses "increment by" x "cache and" start with "to count and take values. 2. The sequence definition, including the content seen from dba_sequences, is stored in the Data Dictionary of the Shared Pool. 3. The officially unpublished sys. v $ _ sequences table also records some sequence information, which is obtained from the Shared Pool. 4. The last_number field in dba_sequences refers to the high water level line or, more accurately, the maximum sequence value stored in the Shared Pool. 5. the cache sequence may be faulty because the cache value is purged. Operations such as flush shared pool may purge the cache. For example, when the Shared Pool is full and the new object (such as SQL) comes again, the old object will be aged out or the ASSM used, buffer cache requires more SGA space, so shrink has a Shared Pool. The fault may occur due to ROLLBACK. The PMON process is cleaned up. Metadata replaces the row cache (that is, Data Dictionary ). The instance is closed. Example:
SQL> create sequence seq_1;Sequence created.SQL> select seq_1.currval from dual;select seq_1.currval from dual       *ERROR at line 1:ORA-08002: sequence SEQ_1.CURRVAL is not yet defined in this sessionSQL> select seq_1.nextval from dual;   NEXTVAL----------         1SQL> select seq_1.nextval from dual;   NEXTVAL----------         2...SQL> select seq_1.nextval from dual;   NEXTVAL----------        20SQL> SELECT last_number FROM dba_sequences WHERE sequence_name='SEQ_1';LAST_NUMBER-----------         21

 


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.