Altering sequence to start from 0

I have a sequence for auto-incrementing a value. Each day I want that sequence to restart, meaning to start from 0 again. So I did a job in which I tried deleting the sequence and re-creating it. Someone told me that instead of deleting-recreating a sequence I can use alter sequence to make the sequence start from 0 again but as I read, the alter sequence cannot do that. as I read:
ALTER SEQUENCE [schema.]sequence
[INCREMENT BY integer]
[MAXVALUE integer | NOMAXVALUE]
[MINVALUE integer | NOMINVALUE]
[CYCLE | NOCYCLE]
[CACHE integer | NOCACHE]
[ORDER | NOORDER]
there is no option to change start from.
Does anyone knows if that can be actually done?
As I figured it's not possible to alter the sequence to start from 0 again I can do a job in oracle to delete and create the sequence again. The thing it it's not working. If I do a job and say:
execute immediate 'drop sequence name_seq'; and execute it, it works, it deletes the squence but if I further write:
execute immediate 'create sequence name_seq ' ||
'start with 1 ' ||
'increment by 1 ' ||
'nomaxvalue ';
it doesn't do it anymore. I get no errors but the sequence is not created. can anyone give me a hand here? 10x a lot in advance

there is no option to change start from.
Does anyone knows if that can be actually done?ensure that noone other works with sequence and:
alter sequence seq increment by -(current_value);
select seq.nextval from dual;
alter sequence seq increment by 1;
execute immediate 'drop sequence name_seq'; and
execute it, it works, it deletes the squence but if I
further write:
execute immediate 'create sequence name_seq ' ||
'start with 1 ' ||
'increment by 1 ' ||
'nomaxvalue '; Looks OK, can you do that from jus SQL prompt?
>
it doesn't do it anymore. So it did a while ago? What has been changed?
Gints Plivna
http://www.gplivna.eu

Similar Messages

  • Can Sequence be started from 0

    I have to create a sequence that starts with 0 and increment by 1.
    I tried is but its return error. Any one help me how to do it.
    create sequence swbofbh_file_number increment by 1 start with 0
    ERROR at line 1:
    ORA-04006: START WITH cannot be less than MINVALUE
    Thanks,
    Atif

    The minvalue defaults to 1, so if you want to start at a value prior to that you have to specify minvalue.
    CREATE SEQUENCE swbofbh_file_number
      START WITH 0
      MINVALUE 0
    /Message was edited by:
    scott.swank

  • Archive start from sequence=2...

    Hi All,
    After completion Database (10g) installation on solaris machine , check the sequence number from v$log view as shown below : it display sequence 2 is current and archive is also start from sequence 2.(check this archive files manually from log_archive_dest_1's location.)
    but when we are looking for any recovery scenarios then will it be asking for archive sequence 1?
    select * from v$log;
    GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS
    1 1 2 52428800 2 NO CURRENT
    2 1 0 52428800 2 YES UNUSED
    3 1 1 52428800 2 YES INACTIVE
    Can any one suggest me why it's start from sequence 2 as current instead of sequence1?
    Thanks...

    Furthermore, read my earlier reply about the backup : "As you haven't taken any Database Backup yet, the archivelogs that are currently being generated will not be required in a Recovery scenario -- you can't begin Restore+Recovery until you have a Backup to Restore."
    Even if log sequence#1 did get archived, it is meaningless. Any archives created before any database backup are unusable in a Recovery situation. A Recovery can apply archivelogs only from the point when a backup was created. You wouldn't, COULDN'T, have taken a Backup before Log Sequence#1 , so there won't be a need for an archive log of that file.
    The situation when Log Sequence#1 is archived is IF a database, being already in ARCHIVELOG mode, is opened with RESETLOGS , for example, after an Incomplete Recovery. Then, the next archive would be Log Sequence#1 of the Incarnation created by the ResetLogs .

  • Audio will only play when started from the beginning of the sequence

    I am running CS5 Premiere Pro on a Mac, the audio plays fine in one of my sequences but only from the beginning of the sequence and on.  If you stop it, or move the play head to any spot on the sequence, then the audio becomes very off and sometimes doesn't even play any sound.  Has anyone else had this issue before?

    I tried that, but it doesn't appear that I have a com.apple.audio.AggregateDevices.plist file in my preferences folder.  I don't even have a com.apple.audio file of any type. 

  • Patch 3480000 install - Failed worker   ALTER SEQUENCE

    Dear All,
    I am in the process of installing Patch 3480000 (11.5.10.2) and during the running workers 1,3 fail and this the part of worker 1 log :
    The sequence IEM_ACCOUNT_TAG_KEYS_S1 in the database is defined as:
    MINVALUE = 1 MAXVALUE = 2000000000 INCREMENT BY = 1
    CYCLE = NO ORDER = NO CACHE = 20
    which should be defined as:
    MINVALUE = 10000 MAXVALUE = 2000000000 INCREMENT BY = 1
    CYCLE = NO ORDER = NO CACHE = 20
    Alter the sequence with :
    Start time for statement below is: Fri Apr 29 2011 14:51:14
    ALTER SEQUENCE IEM.IEM_ACCOUNT_TAG_KEYS_S1 MINVALUE 10000
    AD Worker error:
    The following ORACLE error:
    ORA-04007: MINVALUE cannot be made to exceed the current value
    occurred while executing the SQL statement:
    ALTER SEQUENCE IEM.IEM_ACCOUNT_TAG_KEYS_S1 MINVALUE 10000
    AD Worker error:
    Unable to compare or correct sequences
    *     because of the error above*
    Thanks&BR
    Tarek

    Hussein
    _ this  I did:_*
    **SQL> select IEM.IEM_TAG_KEYS_S1 .nextval from dual;**
    **NEXTVAL**
    **10001**
    **SQL> alter sequence IEM.IEM_TAG_KEYS_S1 increment by 1000;**
    **Sequence altered.**
    **SQL>**
    and this part from screen out put:_+
    **ATTENTION: All workers either have failed or are waiting:**
    **FAILED: file iemsvrp.odf on worker 1.**
    **ATTENTION: Please fix the above failed worker(s) so the manager can continue.**
    **Fixed: file iemsvrp.odf on worker 1 for product iem username IEM.**
    **Restarted: file iemsvrp.odf on worker 1 for product iem username IEM.**
    **FAILED: file iemsvrp.odf on worker 1 for product iem username IEM.**
    **ATTENTION: All workers either have failed or are waiting:**
    **FAILED: file iemsvrp.odf on worker 1.**
    **ATTENTION: Please fix the above failed worker(s) so the manager can continue.**
    and this from log file:+_
    **The sequence IEM_ENCRYPTED_TAG_DTLS_S1 in the database is defined as:**
    **MINVALUE = 1 MAXVALUE = 2000000000 INCREMENT BY = 1**
    **CYCLE = NO ORDER = NO CACHE = 20**
    **which should be defined as:**
    **MINVALUE = 10000 MAXVALUE = 2000000000 INCREMENT BY = 1**
    **CYCLE = NO ORDER = NO CACHE = 20**
    **Alter the sequence with :**
    **Start time for statement below is: Fri Apr 29 2011 17:10:15**
    **ALTER SEQUENCE IEM.IEM_ENCRYPTED_TAG_DTLS_S1 MINVALUE 10000**
    **AD Worker error:**
    **The following ORACLE error:**
    **ORA-04007: MINVALUE cannot be made to exceed the current value**
    **occurred while executing the SQL statement:**
    **ALTER SEQUENCE IEM.IEM_ENCRYPTED_TAG_DTLS_S1 MINVALUE 10000**
    **AD Worker error:**
    **Unable to compare or correct sequences**
    **     because of the error above**
    Thanks hussein
    please advise
    Tarek
    Edited by: user11973469 on Apr 29, 2011 5:17 PM
    Edited by: user11973469 on Apr 29, 2011 5:18 PM

  • How to alter sequence next number

    Can we alter sequence next number. I want to start it from minval.

    To restart the sequence at a different number, you must drop and re-create it.
    If you change the INCREMENT BY value before the first invocation of NEXTVAL, some sequence numbers will be skipped. Therefore, if you want to retain the original START WITH value, you must drop the sequence and re-create it with the original START WITH value and the new INCREMENT BY value.
    Oracle Database performs some validations. For example, a new MAXVALUE cannot be imposed that is less than the current sequence number.

  • How to use identity column in table which value always start from one?

    Hi all,
    Hope doing well,
    sir i created one table which has id with number datatype
    for which i created sequence and stored procedure so suppose
    i inserted two row there it's inserting and id is showing 1, 2
    again i truncate that table and again i inserted value there now the id is starting from 3 , 4
    so my question is that after truncating table can't it insert from 1 in id column?
    thanks,

    >
    sir i created one table which has id with number datatype
    for which i created sequence and stored procedure so suppose
    i inserted two row there it's inserting and id is showing 1, 2
    again i truncate that table and again i inserted value there now the id is starting from 3 , 4
    so my question is that after truncating table can't it insert from 1 in id column?
    >
    Oracle does not have 'identity' columns.
    Oracle sequences are NOT gap free.
    Oracle sequences are independent objects and not associated with any other table or object.
    If you are wanting a gap-free sequnece of numbers, which is not recommended, you will have to create your own functionality. And that functionality will not be scalable or perform well.

  • TS2570 Question re: "Start from your Mac OS X Install disc; use Disk Utility"

    I've worked my way through the step-by-step trouble shooting in the TS2570 article up to "Start from your Mac OS X Install disc; use Disk Utility". So far, every step results in the same outcome - my formerly trusty 2007 Intel duo core iMac (24") will not start up, freezing on a grey screen with a blinking question mark on a folder. I don't completely understand this next step. I have both a Leopard and a Snow Leopard disc. I'm not positive whether these were for the iMac, or my old Macbook Pro. I assume this makes a difference.

    Question (?) Mark, Blinking Folder, or Gray Screen at Startup
    These are related but not identical issues. Their causes are outlined in Intel-based Mac- Startup sequence and error codes, symbols. Solutions may be found in:
    A flashing question mark appears when you start your Mac
    A flashing question mark or globe appears when you start your Mac
    Mac OS X- Gray screen appears during startup
    In most cases the problems may be caused by one or more of these:
    a. Problem with the computer's PRAM - See Resetting your Mac's PRAM and NVRAM.
    b. Boot drive's directory has been corrupted - Repair with Disk Utility.
    c. Critical system files are damaged or deleted - Reinstall OS X.
    d. The disk drive is physically non-functional - Replace the hard drive.
    Note that the information I have provided is what Apple recommends, If other users suggest different solutions than found here, then be sure what they recommend does not impact on your warranty, if any, or ability to get continuing Apple service.
    Please don't start removing drives or changing cables unless you know what you are doing and have exhausted other non-invasive alternatives outlined here. If you perform any work yourself that is unapproved by Apple, then you will void any warranty you may have and lose all further Apple Support.
    Repair the Hard Drive and Permissions
    Boot from your Snow Leopard Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Utilities menu. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
    If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    The main difference if you are using Lion or Mountain Lion is that you must first boot from the Recovery HD. Simply boot from the Recovery HD to perform the above.
    Reinstall Snow Leopard Without Erasing The drive
    1. Repair the Hard Drive and Permissions
    Boot from your Snow Leopard Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Utilities menu. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
    If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    2. Reinstall Snow Leopard
    If the drive is OK then quit DU and return to the installer.  Proceed with reinstalling OS X.  Note that the Snow Leopard installer will not erase your drive or disturb your files.  After installing a fresh copy of OS X the installer will move your Home folder, third-party applications, support items, and network preferences into the newly installed system.
    Download and install Mac OS X 10.6.8 Update Combo v1.1.
    Reinstalling Lion/Mountain Lion Without Erasing The Drive
    Boot to the Recovery HD: Restart the computer and after the chime press and hold down the COMMAND and R keys until the menu screen appears. Alternatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD and click on the downward pointing arrow button.
    Repair the Hard Drive and Permissions: Upon startup select Disk Utility from the main menu. Repair the Hard Drive and Permissions as follows.
    When the recovery menu appears select Disk Utility. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the main menu.
    Reinstall Lion/Mountain Lion: Select Reinstall Lion/Mountain Lion and click on the Continue button.
    Note: You will need an active Internet connection. I suggest using Ethernet if possible because it is three times faster than wireless.

  • Is it possible to edit a MDT Task Sequence after starting a deployment, between Hyper-V snapshots?

    Using a Hyper-V VM, I take snapshots of my base image build between major sections (automatic updates, application installation, scripts and extras, etc.) with the intention of being able to go back to that area and look at it for troubleshooting's sake. 
    Each of these snapshots is manually taken during a pause in my MDT task sequence (using LTISuspend).  I would like to be able to roll back to these snaphots make edits to the task sequence (obviously to sections that haven't yet run), then resume and
    see the changes implemented - but I don't know where the task sequence file(s) resides on VM being imaged, or if that can be changed after kicking it off at the very start of the build. 
    Is it possible to replace the task sequence file (and any other necessary files) that are cached locally on the VM during the imaging process?  Where are those files located?  Or any other way to implement changes to my task sequence so I wouldn't
    have to start the image build completely from scratch?
    This build takes about 6 hours.  Having to make even the slightest modification causes me to lose an entire day, so this would be golden even if I have to manually edit certain files!

    Hi,
    Based on my known, you cannot edit the task sequence after starting the deployment.
    However, I suggest you ask this issue in MDT forum for more professional solution:
    https://social.technet.microsoft.com/Forums/en-US/home?forum=mdt
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn
    from your interaction with us. Thank you for your understanding.
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • I created an application and in  that application if date is changed the application starts from splash screen on re-entering and if date is not changed and u re-enters the application then it open in page where u leaved.Not working in USA timezone.

    I created an application and in  that application if date is changed the application starts from splash screen on re-entering and if date is not changed and u re-enters the application then it open in page where u leaved.It works fine in our side (Timezone,kolkata ,india even for Timezone,slvaniya,USA) but our USA client is telling that on changing the date it not starts from start-up sequence.Can anyone plz suggest the reason for it.

    This is the code which we have used.
    //////////Return if it is first time for the day or not//////////////
    + (BOOL)isFirstTimeToday {
    BOOL result = YES;
    NSDate *now = [[NSDate alloc] init];     /// represents the current time
    NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    NSDateComponents *components = [gregorian components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate: now];
    NSDate *today = [gregorian dateFromComponents:components];
    [now release];
    [gregorian release];
    NSDate *savedDate = [[NSUserDefaults standardUserDefaults] objectForKey:LAST_TIME_VISITED];
    if (savedDate) {
    if ([today earlierDate:savedDate] == today) {
    result = NO;
    return result;
    ////////Stores the date/////////////
    + (void)userDidVisitReenforceScreenToday {
    [[NSUserDefaults standardUserDefaults] setObject:[NSDate todayAtMidnight] forKey:LAST_TIME_VISITED];
    ////////////What [NSDate todayAtMidnight] stores/////////////////////
    + (NSDate *)daysFromNowAtMidnight:(NSInteger)nOfDays {
    NSDate *date = [NSDate dateWithTimeIntervalSinceNow: (86400*nOfDays)];
    NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    NSDateComponents *components = [gregorian components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate: date];
    NSDate *dateAtMidnight = [gregorian dateFromComponents:components];
    [gregorian release];
    NSLog(@"dateAtMidnight : %@",dateAtMidnight);
    return dateAtMidnight;
    + (NSDate *)todayAtMidnight {
    return [self daysFromNowAtMidnight:0];
    Please Suggest..

  • Need to access TestStand Sequence Step Parameters from Excel Macro

    Trying to create an EXCEL spreadsheet containing a list of all steps in a TestStand Sequence including Parameter names and types. How can I access the parameter names and types from EXCEL Visual Basic? It seems the API provides access to sequence parameters, but not step parameters.

    mmghost,
    Unfortunately, in TestStand 2.0, it is not possible to access the step parameter information.
    In TestStand 3.0, there are a few more APIs exposed that give you access to the step parameters. In TestStand 3.0, these are the steps you would take to get that information:
    1) Get a hold of the step object of interest. There are many ways to do this. For instance, starting with the Sequence Context you can get the Sequence object, and then get a step object from the sequence.
    2) From the Step object, get the Module object.
    3) At this point, you need to cast the Module object to the specific adapater type module you are using. For this example, we will assume that we are using the CVI adapter, so we would cast the Module object to a CVIModule o
    bject.
    4) The CVIModule object contains a Parameters collection of type CVIParameters, which contains the type information.
    For different adapter types you would just cast the Module object to a different specific module (LabVIEWModule, ActiveXModule, etc).
    Matt P.
    NI

  • Sequence for starting services in Hyperion  EPMA 11.1.2

    Hi all,
    I have installed the Hyperion and configured it properly. I have change the start up type of all the services to manual now i want to know the sequence of starting the services in Hyperion epma 11.1.2 .
    I know the sequence in 11.1.1.3 but there are some difference in the services from the previous version.
    so please help me.

    The order is listed in Page 204 of http://download.oracle.com/docs/cd/E17236_01/epm.1112/epm_install.pdf
    HTH-
    Jasmine.

  • ALTER SEQUENCE on a busy server results in unexpected very high values

    Our sequence was at 782,393,232 or so, when I bumped it up by 30,000. Here's the commands I used:
    alter sequence OUR_SEQ increment by 30000;
    select OUR_SEQ.nextval from dual;
    alter sequence OUR_SEQ increment by 1;
    commit;
    When I queried the sequence's nextval a few minutes later, it had jumped to over 8 billion !?! I quickly reset down to 783 million or so, and it behaved propertly after that. I've seen a couple of posts on the net that infer that resetting a sequence while it is being heavily used can cause "unpredictable results". Has anyone else experienced this or is there a known bug ?
    I'm running :
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit, RAC system.
    PL/SQL Release 10.2.0.4.0 - Production
    "CORE     10.2.0.4.0     Production"
    TNS for Linux: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production

    Justin Cave wrote:
    Sven,
    I'm not sure that I understand what you're clarifying...
    In a RAC cluster, a sequence with a cache has a separate cache in each node of the cluster. If the cache was set to 20 (the default), and the increment was set to 30,000, each node would cache 20 values each separated by 30,000. And the caches would be non-overlapping (i.e. node A would get the 20 values from 1 - 570,001, node B would get the 20 values from 600,001 - 1,170,001). I don't see that this is at odds with what I posted.
    Obviously, the presence of a cache creates a bit of a wrinkle with when, exactly, you say that a sequence is incremented. The NEXT_VALUE in DBA_SEQUENCES is incremented by cache*interval when any node exhausts its cache. The NEXTVAL of a sequence for connections that are hitting a particular node will increase by interval each time some other session gets the NEXTVAL of a sequence. The NEXTVAL of a sequence for connections on a different node is unaffected by what is happening on the current node. Is that the clarification you're making? If so, I agree.
    user11300030,
    The discussion on sequence caching may provide some insight into why none of the rows are between 780 million and 1 billion. It's entirely possible that those values were cached on a node other than the node where the inserts were run. Had the caches not been flushed when you altered the sequence, inserts run on those other nodes might have used the values from that range.
    JustinWe do have two nodes and the sequence cache size was 100, so what you suggested in your last paragraph makes sense.
    Also, I just ran an AWR report and noted that "select our_seq.nextval from dual" was called 280K times (Hibernate is a hungry beast).

  • Photodownloader - Error in sequencing files copied from CF Card

    I'm a relatively new user of Bridge and the Photodownloader there (although I've used Elements and it appears to be very similar).  I've noticed that when I copy files from my CF card (from  nikon 300s) that the sequence of the file names on the CF card does not identically match the sequence of the files that are copied to my PC.
    I noticed the issue when working with sports photos.  The sequence that ACR was presesnting to me was wrong in some instances. In the two I checked it was the same type of error.  Pictures that were in 1-2-3 seqence on the CF card were in 3-1-2 sequence after copying.  The sequence on the CF card was correct. It does not do it all the time, but seems to be in shots that were shot in faster sequence.
    There doesn't seem to be much to mess up with the settings. I tell it to rename to a custom name + date + sequence # (usually starting with 1).
    Has anyone else run into this?  Is it a bug in Photodownloader?  Am I doing something wrong?
    I'm using Bridge CS4 - 3.0.0.464.

    Film4Now wrote: What do you suggest as an alternative for a file loader and renaming tool?  I like the other functionality that Bridge brings with ACR.  I use the editing features in that a lot.
    I use all the features of Bridge CS4 (except that one) and love it!
    Vista has a useful import module but I don't know if it would suit your purposes.
    Then again most cameras come with some facility for this too.
    With CS5 getting closer I doubt whether the downloader will ever be fixed.

  • How to alter sequence?

    hello gurus,
    i have a sequence like this
    CREATE SEQUENCE  seq_idea
      START WITH 6
      MAXVALUE 9999999999
      MINVALUE 1
      NOCYCLE
      NOCACHE
      NOORDER;i want to change the start with as 100 ,can any one tell me how to alter sequence
    regards,
    friend

    most wanted!!!! wrote:
    hello gurus,
    i have a sequence like this
    CREATE SEQUENCE  seq_idea
    START WITH 6
    MAXVALUE 9999999999
    MINVALUE 1
    NOCYCLE
    NOCACHE
    NOORDER;i want to change the start with as 100 ,can any one tell me how to alter sequence
    regards,
    friendDrop it and recreate it with the appropriate start with value.

Maybe you are looking for