2 Replies Latest reply: Oct 16, 2012 10:21 AM by rp0428 RSS

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

    955649
      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,
        • 1. Re: How to use identity column in table which value always start from one?
          berx
          Hi,

          you are probably asking in the wrong forum.
          I'd suggest [url https://forums.oracle.com/forums/forum.jspa?forumID=75]SQL and PL/SQL.

          I am sure there are plenty of people which will help you in high quality.

          A small hint: the numbers for your ID are related to the sequence, not the table.

          Martin
          • 2. Re: How to use identity column in table which value always start from one?
            rp0428
            >
            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.