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 4624384
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:07:19+00:00 2026-05-22T03:07:19+00:00

Ok say I have a table with two columns. Entry_id and name. Entry_id is

  • 0

Ok say I have a table with two columns. Entry_id and name. Entry_id is a ROWID NOT NULL.
Essentially I just want it to increment every time something new is put in. How do i do this in the PreparedStatement. I won’t know the correct Entry_id bc it doesn’t matter. It should just increment everytime. So it would be nice if i could just insert the name into the table and entry_id increments automatically. Any idea how to do this?

  • 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-05-22T03:07:20+00:00Added an answer on May 22, 2026 at 3:07 am

    A ROWID is a physical address for a row in a table. It does not make sense to use a ROWID as a key– a ROWID will change over time if a table is moved from one tablespace to another, if you do an export and import, if row movement occurs, etc. And it does not make sense to increment a ROWID since the result would quite likely be invalid either in the sense that it would no longer be the physical address of an actual row or that it would not longer be a valid physical address.

    If you want an auto-incrementing primary key in Oracle, you would declare the column as a NUMBER, not a ROWID. You would then create a sequence object

    CREATE SEQUENCE entry_id_seq
      START WITH 1
      INCREMENT BY 1
      CACHE 100;
    

    and reference the NEXTVAL of that sequence in your INSERT statement

    INSERT INTO entry( entry_id, name )
      VALUES( entry_id_seq.nextval, :1 );
    

    Of course, you could create a before-insert trigger to populate the primary key from the sequence

    CREATE OR REPLACE TRIGGER get_entry_id
      BEFORE INSERT ON entry
      FOR EACH ROW
    IS
    BEGIN
      SELECT entry_id_seq.nextval
        INTO :new.entry_id
        FROM dual;
    END;
    

    Your INSERT statement could then omit the ENTRY_ID column, letting the trigger automatically populate it.

    INSERT INTO entry( name )
      VALUES( :1 );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have a table with just two columns: name and mood .
Say I have table with two columns: Name, Age. I want to design a
Say I have an MSSQL table with two columns: an int ID column that's
I have two tables with similar columns - let's say table A with column
Say I have two tables I want to join. Categories: id name ---------- 1
I have a table with two columns, customer id and order. Let's say I
Say you have table of some items with these two columns: ItemName Price ....where
Let's say I have two tables: Table: Color Columns: Id, ColorName, ColorCode Table: Shape
Let's say I have a table with two columns, where a user places a
Let's say I have a table with two columns, one column for the ID

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.