Results 1 to 5 of 5

Thread: Increasing primary key values in database

  1. #1
    Join Date
    Nov 2009
    Posts
    43

    Increasing primary key values in database

    Hi everyone !
    I am creating a table with some constraint and the primary key constraint is also included in the table but I have some problem regarding implementation.Can any one tell me about the auto increment behavior of primary key value. How it would be performed. I need to increase the values of primary key with every record. Please help me for implementation of this table record.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Increasing primary key values in database

    Increasing the value of Primary Key :

    You can increase the values of primary key column or any column which you want to increase whenever you required.The oracle database provides a technique to solve this issue.

    The Sequence, is the object of database which can perform this task using related parameter.Using CREATE SEQUENCE statement,create a sequence and implement it with your table column.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Creating sequence in database

    Creating sequence :

    The CREATE SEQUENCE statement would be used to create the sequence object.Follow the below statement :

    Code:
    CREATE SEQUENCE product_seq
     START WITH     1000
     INCREMENT BY   1
     NOCACHE
     NOCYCLE;
    Where START WITH is used for first sequence number to be generated.
    The INCREMENT BY option Specify the interval between sequence numbers which can be negative and positive both.
    NOCACHE is used to specify how many sequence values can be stored in the cache memory.
    NOCYCLE is used to indicate that the sequence cannot generate more values after it higher and lower value which is default behavior.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Increasing primary key values in database

    Implementing sequence :

    After creation of sequence in database, you can implement it into your statement . I am going to show you an example which will increase the value of student_id column which is the primary key of Student_info table.The sequence has been created named seq_Student_id" and would be
    used as follows :

    Code:
    INSERT INTO Student_info
    (student_id, Student_name, Address)
    VALUES
    (seq_Student_id.NEXTVAL, 'Wilson', 'Washington........');

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    Configuring the values of sequence

    Configuring the values of sequence :

    You can configure the sequence behavior means different values that you have set up for particular options before,you can edit it according to your need using below statement :

    ALTER SEQUENCE <Sequence_name> <Option_name> <value>;

    Where Sequence_name is the name of sequence, Option_name is the name of option i.e.INCREMENT BY and the last is the value,set the value whatever you want

    Dropping sequence :

    You can drop the sequence using DROP statement :

    DROP SEQUENCE <sequence_name>;

Similar Threads

  1. W32 registry values are not getting matched by the default values
    By Angrzej in forum Networking & Security
    Replies: 5
    Last Post: 19-05-2011, 12:23 PM
  2. Defining primary key on database table
    By Garlands in forum Software Development
    Replies: 4
    Last Post: 09-02-2010, 09:09 PM
  3. How to Get the values from the database in ASP?
    By - Empty Shell - in forum Software Development
    Replies: 5
    Last Post: 03-02-2010, 02:33 AM
  4. How to write the form values in Database using C#
    By Aienstaien in forum Software Development
    Replies: 3
    Last Post: 20-08-2009, 03:36 PM
  5. Replies: 2
    Last Post: 03-06-2008, 03:16 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,222,257.57442 seconds with 17 queries