# Starting record id is 10000 in oracle 10g ,why?

**URL:** <https://www.ruby-forum.com/t/starting-record-id-is-10000-in-oracle-10g-why/140181>\
**Category:** Rails\
**Created:** [June 11, 2008, 4:58pm UTC](https://www.ruby-forum.com/t/starting-record-id-is-10000-in-oracle-10g-why/140181 "2008-06-11T16:58:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mokkai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@mokkai](https://www.ruby-forum.com/u/mokkai)\
**Post date:** [June 11, 2008, 4:58pm UTC](https://www.ruby-forum.com/t/starting-record-id-is-10000-in-oracle-10g-why/140181/1 "2008-06-11T16:58:28Z")

</div>

i create a new model(User) and create a new record  
(User.create(attributes)) in oracle  
when i check User.find 1 in console  
it gives record not found error

when i try  
User.find(:first).id --\> 10000

how to change this starting id into 1 …

---

<div class="post-metadata">

**Author:** ![mokkai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@mokkai](https://www.ruby-forum.com/u/mokkai)\
**Post date:** [June 11, 2008, 5:52pm UTC](https://www.ruby-forum.com/t/starting-record-id-is-10000-in-oracle-10g-why/140181/2 "2008-06-11T17:52:09Z")

</div>

On Jun 11, 10:58 am, Pokkai D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> i create a new model(User) and create a new record  
> (User.create(attributes)) in oracle  
> when i check User.find 1 in console  
> it gives record not found error
> 
> when i try  
> User.find(:first).id → 10000
> 
> how to change this starting id into 1 …

The following lines are in oracle\_adapter.rb

```
    def create_table(name, options = {}) #:nodoc:
      super(name, options)
      seq_name = options[:sequence_name] || "#{name}_seq"
      execute "CREATE SEQUENCE #{seq_name} START WITH 10000"

```

unless options[:id] == false  
end

I don’t know why they decided to hard-code the 10000 in there. It  
would be nice if you could override it. I suggest submitting an  
enhancement request to the ruby-oci8 maintainer. A simple patch would  
be

```
    def create_table(name, options = {}) #:nodoc:
      super(name, options)
      seq_name = options[:sequence_name] || "#{name}_seq"
      start_num = options[:start_with] || 10000
      execute "CREATE SEQUENCE #{seq_name} START WITH

```

#{start\_num}" unless options[:id] == false  
end

assuming the class chain starting with ActiveRecord::Migration passes  
all the options through. In the mean time you could monkey patch the  
class with the above method yourself.

Mark.

---

<div class="post-metadata">

**Author:** ![mokkai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@mokkai](https://www.ruby-forum.com/u/mokkai)\
**Post date:** [June 12, 2008, 8:13am UTC](https://www.ruby-forum.com/t/starting-record-id-is-10000-in-oracle-10g-why/140181/3 "2008-06-12T08:13:15Z")

</div>

> I don’t know why they decided to hard-code the 10000 in there. It  
> would be nice if you could override it. I suggest submitting an  
> enhancement request to the ruby-oci8 maintainer. A simple patch would  
> be
> 
> ```
> def create_table(name, options = {}) #:nodoc:
> super(name, options)
> seq_name = options[:sequence_name] || "#{name}_seq"
> start_num = options[:start_with] || 10000
> execute "CREATE SEQUENCE #{seq_name} START WITH
> 
> ```
> 
> #{start\_num}" unless options[:id] == false  
> end
> 
> Mark.

thanks
