Creating sequence without cach

how can i create a sequence without cach to reduce the possibility of gabs

http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_615a.htm#2067096
Try search before you ask question.

Similar Messages

  • How to create sequence when minvalue is unknown?

    I am currently migrating a lot of tables (that already have data) over to using sequences. I'd like to have a script that creates these sequences without having to hardcode the minimum value that the sequence should start at.
    I am trying to do something like this:
    create sequence mySeq minvalue (select max(id)+1 from table) increment BY 1 cache 20;
    This always gives the error "Invalid number". Can anyone provide some guidance on how to solve this problem?

    Like this..?
    SQL> declare
      2   min_val number;
      3   str varchar2(1000);
      4  begin
      5   select nvl(max(empno),0)+1
      6   into min_val
      7   from emp;
      8   str := 'create sequence seq1 start with '||min_val||' increment by 1 cache  20';
      9   execute immediate str;
    10  end;
    11  /
    PL/SQL procedure successfully completed.
    SQL> select seq1.nextval
      2  from dual;
       NEXTVAL
          7935
    http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_dynamic_sql.htm#i1006172                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Proving that sequence is cached in SGA

    Hello,
    I spent all day researching this yesterday without an answer - the information must be out there somewhere but I can't find it!
    We know that when a sequence is created with CACHE 20 the values are generated 20 at a time and stored in the SGA. We also know that Oracle may choose to age these values out of SGA if the sequence is infrequently used (and for other reasons too).
    I am trying to understand how to prove that a set of values is currently being cached for a particular sequence. I expect to be able to see a difference somewhere in memory between a sequence with CACHE 20 and a sequence created with NOCACHE - this is reproduceable. I also wish to be able to prove whether or not a sequence created with the CACHE option has been aged out of the SGA (this is more difficult to reproduce).
    I looked in v$bh but this does not seem to contain sequences (I believe they are cached in library cache since Oracle 8?).
    V$db_object_cache seems to contain a row for the sequence regardless or whether it was created with the CACHE option and there does not seem to be a pattern in the value of SHARABLE_MEM.
    There are views available to see the contents of the buffer cache right down to the block level - is there something similar for the pool which contains sequences?
    Thanks.

    Hi Dom,
    I'm hoping to write a script which I can run for a current point in time snapshot, rather than something I need to configure and monitor.
    For example I use v$bh to see the buffer cache contents (right down to block level if necessary). I just assume there must be a data dictionary view somewhere that will contain a row for the sequence if it has values cached in the library and no row if there are no values cached.
    I am assuming that the information is in the dictionary somewhere and I just don't know where to look, but perhaps it isn't there at all. Oracle internals can obviously track whether it needs to get nextval from memory or via a latch to disk but perhaps this information hasn't been opened up for us to see.

  • Sequence losting cache

    Hi, I have some sequences in cache and i'm losing the cache with the instance "ON".
    I'm using 10g.
    The sequence's cache uses LRU list? What can I do?
    Thanks.

    The sequence cache is in the library cache.
    You will loose sequences by bouncing the instance amongst other.
    This is not a problem, as sequences are used for surrogate keys, and as surrogate keys don't have a meaning (except for bean counters), you can have a surrogate key with holes.
    If you want to minimize the impact create your sequences with the nocache clause.
    If you want a surrogate without holes, revert to the sequence table. Remember this 'solution' scales badly.
    Sybrand Bakker
    Senior Oracle DBA

  • CREATE SEQUENCE from a stored procedure

    Hello,
    Is it possible, to create a sequence object from an own written stored procedure? Can I reinitialize the actual value of a sequence object without recreating it from a stored procedure?
    Thank you for recommendations,
    Matthias Schoelzel
    EDV Studio ALINA GmbH
    Bad Oeynhausen

    maybe this example might be of some help.
    SQL> create or replace procedure dy_sequence (pSeqName varchar2,
      2                                           pStart number,
      3                                           pIncrement number) as
      4    vCnt     number := 0;
      5  begin
      6    select count(*) into vCnt
      7      from all_sequences
      8     where sequence_name = upper(pSeqName);
      9 
    10    if vCnt = 0 then
    11      execute immediate 'create sequence '||pSeqName||
    12                        ' start with '||to_char(pStart)||
    13                        ' increment by '||to_char(pIncrement);
    14    else
    15      execute immediate 'alter sequence '||pSeqName||' increment by '||to_char(pIncrement);
    16    end if;
    17  end;
    18  /
    Procedure created.
    SQL> -- create the sequence by calling the dy_sequence procedure
    SQL> execute dy_sequence ('test_sequence',1,1);
    PL/SQL procedure successfully completed.
    SQL> select test_sequence.nextval from dual;
       NEXTVAL
             1
    SQL> -- alter the sequence to increment by 2
    SQL> execute dy_sequence ('test_sequence',0,2);
    PL/SQL procedure successfully completed.
    SQL> select test_sequence.nextval from dual;
       NEXTVAL
             3
    SQL>

  • Assigning a 'dynamically created sequence' value to a variable

    in my procedure i am creating a sequence on the fly, i am preparing the name with some passed parameters like below
    v_seq_name := 'seq_'||loadid||v_table_name;
    execute immediate 'CREATE SEQUENCE '||v_seq_name||' MINVALUE 1 MAXVALUE 999999999999999999999999999 START WITH 1 increment by 1 cache 20';
    and now after doing some operations i need to assign the current value of sequence to a number variable i tried following but not working
    1) v_curr_value : = v_seq_name.currval ;
    2) select v_seq_name||'.nextval' into v_curr_value from dual;
    can you please suggest me how i can get the value in plsql block.

    DIVI wrote:
    in my procedure i am creating a sequence on the fly, i am preparing the name with some passed parameters like below
    v_seq_name := 'seq_'||loadid||v_table_name;
    execute immediate 'CREATE SEQUENCE '||v_seq_name||' MINVALUE 1 MAXVALUE 999999999999999999999999999 START WITH 1 increment by 1 cache 20';
    and now after doing some operations i need to assign the current value of sequence to a number variable i tried following but not working
    1) v_curr_value : = v_seq_name.currval ;
    2) select v_seq_name||'.nextval' into v_curr_value from dual;
    can you please suggest me how i can get the value in plsql block.Well, you haven't given the error you are getting but I guess the procedure isn't compiling? You need to execute immediate any reference to the sequence.
    Having said that, your architecture is probably wrong if you are dynamically creating things in a procedure.
    Why do you need to create them dynamically?

  • Issue in creating Sequence

    Hi All,
    I am using
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - ProductionI have schema with following roles
    ALTER ANY OUTLINE
    CREATE ANY OUTLINE
    CREATE ANY SYNONYM
    CREATE DATABASE LINK
    CREATE MATERIALIZED VIEW
    CREATE PUBLIC DATABASE LINK
    CREATE VIEW
    DROP ANY OUTLINE
    DROP PUBLIC DATABASE LINK
    SELECT ANY TABLE
    UNLIMITED TABLESPACE
    CONNECT
    DBA
    EXP_FULL_DATABASE
    IMP_FULL_DATABASE
    OEM_MONITOR
    RESOURCEI can able create a sequence through SQLPLUS as well as from toad.
    SQL> CREATE SEQUENCE ROLE_ACTIVITY_SEQ START WITH 225006249 INCREMENT BY 1 MAXVALUE 9999999999999999999 MINVALUE 225006249 NOCYCLE CACHE 100 ORDER;
    Sequence created.
    SQL>when i try to create sequence dynamically through PL/SQL procedure getting error
    SQL> execute PROC_CLONE_BU;
    BEGIN PROC_CLONE_BU; END;
    ERROR at line 1:
    ORA-01031: insufficient privileges
    ORA-06512: at "SUPERNOVA.PROC_CLONE_BU", line 19
    ORA-06512: at line 1
    SQL>Even though I have DBA role for the schema. I don't know what privileges oracle still excepting..
    Pls guide me to resolve it..
    Thanks & Regards
    Sami

    Hi All,
    As said early creating sequence through dynamic SQL
    its creating sequence fine but when i try to use sequence in same procedure then procedure getting error..
    create or replace procedure proc_seq_genrate as
    begin
    EXECUTE IMMEDIATE 'CREATE SEQUENCE BU_ROLE_DSK_ITEM_SEQ START WITH 100 INCREMENT BY 1 MAXVALUE 9999999999999999999 '||
    'MINVALUE 100 NOCYCLE CACHE 100 ORDER';--- hard coded value 100 will changed according to  PK max value of the table .. for getting max value i will write SQL Query
    end;
    Procedure created.
    create or replace procedure proc_seq_genrate as
    begin
    EXECUTE IMMEDIATE 'CREATE SEQUENCE BU_ROLE_DSK_ITEM_SEQ START WITH 100 INCREMENT BY 1 MAXVALUE 9999999999999999999 '||
    'MINVALUE 100 NOCYCLE CACHE 100 ORDER';--- hard coded value 100 will changed according to  PK max value of the table .. for getting max value i will write SQL Query
    INSERT INTO ROLE_ACTIVITY (SELECT ROLE_ACTIVITY_SEQ.NEXTVAL, -98, ACTIVITY_CD, REC_ST, 1, ROW_TS, USER_ID, CREATE_DT, SYS_CREATE_TS, CREATED_BY FROM ROLE_ACTIVITY WHERE ROLE_ID=-99 );
    end;
    7     35     PL/SQL: ORA-02289: sequence does not existI have understood that its looking for Sequence but
    pls any one explain me why its looking sequence in compile time itself.. any way we are going to use the sequence only at run time right.. i would like to know is there any technical reason behind this..
    Thanks & regards
    Sami.

  • Creating sequences for all tables in the database at a time

    Hi ,
    I need to create sequences for all the tables in my database.
    i can create individually ,using toad and sqlplus.
    Can any one give me a code for creating the sequences dynamically at a time for all the tables.
    it is urgent ..
    Regards.

    I need to create sequences for majority of the tables that are having ID column
    which is sequences."The majority" is not the same as all. So you probably want to drive your generation script off the ALL_TAB_COLUMNS view...
    where column_name = 'ID'You need to think about this carefully. You might want different CACHE sizes or different INCREMENT BY clauses for certain tables. You might even (whisper it) want a sequence to be shared by more than one table.
    Code generation is a useful technique, but it is a rare application where one case fits all.
    Cheers, APC
    Blog : http://radiofreetooting.blogspot.com/

  • Create Sequence Number with Select Query

    Hi All,
    I would like to create a sequence number in oracle but instead of hard coding the "start with" I want to select the max value of the primary key of a table and add 1 and use this instead:
    So what I want is:
    CREATE SEQUENCE crg_mrec_seq
    MINVALUE 1
    MAXVALUE 999999999999999999999999999
    START WITH select max(primarykey)+1 from table1
    INCREMENT BY 1
    CACHE 20;I'm guessing I need to pass this max value as a variable into the create sequence number but I'm not sure what syntax to use.
    Thanks,
    Ed

    spalato76 wrote:
    Hi All,
    I would like to create a sequence number in oracle but instead of hard coding the "start with" I want to select the max value of the primary key of a table and add 1 and use this instead:
    So what I want is:
    CREATE SEQUENCE crg_mrec_seq
    MINVALUE 1
    MAXVALUE 999999999999999999999999999
    START WITH select max(primarykey)+1 from table1
    INCREMENT BY 1
    CACHE 20;I'm guessing I need to pass this max value as a variable into the create sequence number but I'm not sure what syntax to use.
    Thanks,
    Edconstruct SQL statement & then EXECUTE IMMEDIATE

  • Create sequence on report

    Help please.
    I am trying to create sequence on the report. I wrote following PLSQL on the field emp_no in order to show sequence number (1,2,3...)on the employee_no column. It did not work.
    CREATE SEQUENCE Emp_sequence
    INCREMENT BY 1
    START WITH 1
    NOMAXVALUE
    NOCYCLE
    CACHE 10;
    is this correct PLSQL? should we put the PLSQL on trigger or field?
    Thank's in advance!

    Sequence is an DDL. So dynamic sql utility package
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by antony:
    Help please.
    I am trying to create sequence on the report. I wrote following PLSQL on the field emp_no in order to show sequence number (1,2,3...)on the employee_no column. It did not work.
    CREATE SEQUENCE Emp_sequence
    INCREMENT BY 1
    START WITH 1
    NOMAXVALUE
    NOCYCLE
    CACHE 10;
    is this correct PLSQL? should we put the PLSQL on trigger or field?
    Thank's in advance!<HR></BLOCKQUOTE>
    null

  • Cannot create sequence with nocache

    hi there,
    actual I try Raptor build 919 and I have a problem with creating sequences with NOCACHE using the wizzard.
    When I want to create a sequence with NOCACHE, the DDL shown in the wizzard is: CREATE SEQUENCE SEQUENCE1 INCREMENT BY 1 START WITH 1 MAXVALUE 10 MINVALUE 1 ;
    So the sequence is created with CACHE and cache size 20. After creating it is possible to switch the sequence to NOCACHE.

    I just checked in our bug database and this was fixed in our development version 1060 so it will be fixed in our next Early Adopter release (post v919).
    -- Sharon

  • Create sequence

    in create sequence statement what z the use of cache/nocache?please tell me briefly.

    810045 wrote:
    in create sequence statement what z the use of cache/nocache?please tell me briefly.Fortunately this is described in the manuals that you refuse to read.
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/statements_6015.htm#i2067093
    >
    CACHE
    Specify how many values of the sequence the database preallocates and keeps in memory for faster access. This integer value can have 28 or fewer digits. The minimum value for this parameter is 2. For sequences that cycle, this value must be less than the number of values in the cycle. You cannot cache more values than will fit in a given cycle of sequence numbers. Therefore, the maximum value allowed for CACHE must be less than the value determined by the following formula:
    (CEIL (MAXVALUE - MINVALUE)) / ABS (INCREMENT)
    If a system failure occurs, then all cached sequence values that have not been used in committed DML statements are lost. The potential number of lost values is equal to the value of the CACHE parameter.
    Note:
    Oracle recommends using the CACHE setting to enhance performance if you are using sequences in an Oracle Real Application Clusters environment.
    NOCACHE
    Specify NOCACHE to indicate that values of the sequence are not preallocated. If you omit both CACHE and NOCACHE, then the database caches 20 sequence numbers by default.

  • Sequence and Cache

    I created a sequence:
    SQL> create sequence s
    increment by 1
    start with 1;
    then,
    SQL> select s.nextval from dual;
    1
    SQL> select s.nextval from dual;
    2
    it works fine.
    But when I shutdown my Windows2000 Server (where Oracle 9i is installed) and restart it again...
    SQL> select s.nextval from dual;
    32
    The default cache for sequence is 20.
    After reboot, the cahched sequence number are lost!
    Is there any way to keep the cached sequence number after reboot?
    What if I do the following: "SQL> alter sequence s cache 0; " ???
    What if the side-effect if I set the cache to 0 ??? Do you suggest to set it to zero ?
    thank you very much.
    Chu Ka Keong

    Just to elaborate a bit on Don's post.
    If you want to minimize the number of holes in a sequence, you must use the NOCACHE option when creating the sequence (or alter it that way). Be aware that this will NOT eliminate holes in the sequence. Any transaction that gets a value from the the sequence, and then rolls back, or otherwise does not write to the table, will "waste" a sequence number.
    Having said that, who really cares. The only, and I emphasise only, use for a sequence is to generate a guaranteed unique number for some purpose, either an ID, or a sequential number to make an otherwise duplicated key unique. Personally, I see absolutely no reason for a sequence in the second case.
    If you expect multiple users, and frequent "hits" to your sequence, use a big cache (I have some that cache 500) and damm the holes.

  • Why is an OST created even if Cached Exchange mode is disabled?

    We have run into performance issues on our VDI environment which have been traced to Outlook. By default Cached Exchange Mode is enabled, this obviously creates an OST file. However, if this is disabled, either by GPO or in the registry and the OST file
    is deleted, it creates another one anyway. The problem is we use non persistent with persona machines, so every time a user logs on it pulls a new machine, creates the OST in their persona then copies this OST to the C drive. This results in up to 10 minutes
    between pulling the machine and being able to do anything.
    Looking deeper into it there is another setting needed in the GPO or DWORD in the registry to not allow creation of an OST, see below
    My question is why on earth is an OST created even if Cached Exchange mode is disabled? Why is this second setting even there? By definition if you are not using Cached Exchange mode, you do not need to have an OST so this just seems redundant and annoying.

    Hi,
    Outlook has one Online mode but two offline modes: Exchange Cached mode and Offline Folders. Although Outlook 2013 doesn't use true offline folders, only cached mode, you need to disable offline folders along with cached mode to prevent it and older versions
    of Outlook from creating an OST file for offline use.
    I think it should work if you have applied the GPO, or the registry values below:
    Important
    This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the
    registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry,
    http://windows.microsoft.com/en-US/windows7/Back-up-the-registry
    HKEY_CURRENT_USER\Software\Policies\Microsoft\office\15.0\outlook\cached mode
    DWORD: enable
    Value: 0
    HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Outlook\OST
    DWORD: NoOST
    Value: 2
    NoOst value specifies whether or not an OST is created at startup. Setting the
    NoOst value to 2 will prevent the use of OST files. A value of 3 will allow OST files for cached mode but won't create one when online mode is used.
    The explanation above is quoted from Diane Poremsky's article:
    http://www.slipstick.com/exchange/outlook-online-mode-creates-ost-file/
    Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.
    Regards,
    Melon Chen
    Forum Support
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please click
    here

  • Reg:Creating Sequence

    hi
      can you anyone please tell me how to create sequence in xmii suppose if i use syntax like this
       CREATE SEQUENCE supplier_seq
        MINVALUE 1
        MAXVALUE 999999999999999999999999999
        START WITH 1
        INCREMENT BY 1
        CACHE 20;
    its showing an error
    <b>A SQL Error has occurred on query, ORA-00911: invalid character
    Thanks in advance

    Hi DevaKrishnan,
                                 u can use the same as used first , that is
                                      CREATE SEQUENCE supplier_seq
                                       MINVALUE 1
                                       MAXVALUE 999999999999999999999999999
                                       START WITH 1
                                       INCREMENT BY 1
                                       CACHE 20        
       and  choosing the same mode(command) the only difference is remove the semicolon  then it works fine.
    Regards,
    chaitanya

Maybe you are looking for