Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle start Sequence from 1

I am maintaining a database using Oracle 10g and I would like to have a sequence that starts from 1 and increments by 1 with each additional row.

I have created the following statement in order to achieve this:

CREATE SEQUENCE PATIENTS_SEQ START WITH 1 INCREMENT BY 1 NOMINVALUE NOCACHE NOCYCLE;

However, upon inserting the first entry into the table with value (PATIENTS_SEQ.NEXTVAL), the count starts at 2 instead of 1. If I modify my sequence to start with 0, then I get an error that the start with value cannot be less than the minvalue. Can anyone help troubleshoot how to get my count to start properly from 1?

like image 588
raphnguyen Avatar asked Mar 15 '13 17:03

raphnguyen


1 Answers

Simply set the minvalue to 0 as well:

CREATE SEQUENCE PATIENTS_SEQ 
  START WITH 0 
  INCREMENT BY 1 
  MINVALUE 0 
  NOCACHE 
  NOCYCLE;
like image 128
a_horse_with_no_name Avatar answered Nov 15 '22 04:11

a_horse_with_no_name