Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9010531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:29:09+00:00 2026-06-16T02:29:09+00:00

I have an oracle database table: CREATE TABLE DogInfo ( Id NUMBER NOT NULL

  • 0

I have an oracle database table:

CREATE TABLE "DogInfo" (
"Id" NUMBER NOT NULL ENABLE,
"DogName" VARCHAR2 (50 CHAR) NOT NULL ENABLE,
"DogAge" NUMBER NOT NULL ENABLE,
CONSTRAINT "DogInfo_PK" PRIMARY KEY ("Id") ENABLE
);

CREATE SEQUENCE "DOGINFO_SEQ" MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE;

CREATE OR REPLACE TRIGGER  "BI_DogInfo" 
BEFORE INSERT ON "DogInfo" FOR EACH ROW
WHEN (NEW."Id" IS NULL OR NEW."Id" = 0) BEGIN
    SELECT "USERINFO_SEQ".nextval INTO :NEW."Id" FROM dual;
END;

ALTER TRIGGER  "BI_DogInfo" ENABLE;

If I insert 20 records into the table with database tool, and then use my C# web application to insert records, the dog id will start with 1, rather than 21.

Anyone can help me fix this bug?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:29:11+00:00Added an answer on June 16, 2026 at 2:29 am

    Sequence is not an “auto increment id”.

    Sequence is just a sequential unique number generator. It can work as your Id column value provider but it is up tu You to keep proper values in the column.

    I assume that You add your 20 rows like this:

    insert into table(id, <columns>) values (1, <values>);
    insert into table(id, <columns>) values (2, <values>);
    and so on ...
    

    Your sequence has no way of knowing what is the next number you “expect” it to have (unless of course you (re)create it with desired initial value).
    Instead You should always use values from your sequence like this:

    insert into table(id, <columns>) values (sequence.nextval, <values>);
    insert into table(id, <columns>) values (sequence.nextval, <values>);
    and so on ...
    

    This way you’ll keep sequence in sync with table id values.

    EDIT :

    You can imitate that behaviour by using trigger and sequence as described in this answer.

    Also IDENTITY column is now available on Oracle 12c

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a table: CREATE TABLE TABLE_NAME ( COLUMN_1 char(12) NOT NULL, COLUMN_2
I have a oracle table called: create table InsertHere( generate_id varchar2(10), name varchar2(100) );
I have a table (Oracle database) that looks like: CREATE TABLE example ( idEx
I have created a table on an Oracle 10g database with this structure :
I have two columns(column1, column2) in my oracle database table named as demo .
We have a Oracle 9i database and OrderDetails table which has a column to
I have 3 columns in Oracle database having table mytable and i want records
I have an oracle 10g database that has 2 tables: a REBATES table, and
we have a table in an Oracle Database which contains a column with the
I have a table in an Oracle Database that has, among others, a DATE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.